Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Fetch XML passing parameters in C#?

$
0
0

All,

I need help with passing a c# variable into my fetch xml code. Can someone tell me if this is possible?

Using this sample code below, how can I pass the VALUE argument into the fetch xml for the ORDER CLOSED filter criteria so it's not hard coded?

Sample code:

int value = 1;  

string fetchXml =
                          @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='salesorder'> 
                                                 <attribute name='salesorderid'/>
                                                <attribute name='ordernumber'/>
                                                <attribute name='salesorderid' />  
                                                <attribute name='customerid'/>
                                                <attribute name='statuscode'/> 
                                                <attribute name='totalamount'/>  
                                                <attribute name='salesorderid' />
                                                <attribute name='billto_name' /> 
                                                <attribute name='billto_city' /> 
                                                <attribute name='billto_stateorprovince' /> 
                                                <attribute name='billto_postalcode' /> 
                                                <attribute name='billto_telephone' />    
                                                <attribute name='description' />   
                                                <attribute name='shipto_contactname' /> 
                                                <attribute name='shipto_telephone' /> 
                                                <attribute name='shipto_fax' /> 
                                                <attribute name='shipto_line1' />
                                                <attribute name='shipto_line2' />
                                                <attribute name='shipto_city' />
                                                <attribute name='shipto_stateorprovince' />
                                                <attribute name='shipto_postalcode' />
                                                <attribute name='shipto_country' />  
                                                <attribute name='totalamount' />   
                                      <filter type='and'>
                                         <condition attribute='orderclosed' operator='eq' value='1' />  
                                           </filter> 
  </entity>
</fetch>";


// passed into the filter criteria rather than hard coding.
int val = 1; 
<filter type='and'> <condition attribute='orderclosed' operator='eq' value='1' /> </filter>

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>