Reputation: 169
I want to update the data in DCRM-2011 by executing query like,
update customers set customer_name='SUDHIL-2' where customer_id in('CU102','CU103')
How can I achieve this via Execute-Request UpdateRequest? My SOAP request is as below,
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request i:type="a:UpdateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<b:key>Target</b:key>
<b:value i:type="a:Entity">
<a:Attributes>
<a:KeyValuePairOfstringanyType>
<b:key>customer_name</b:key>
<b:value i:type="a:OptionSetValue">
<a:Value>SUDHIL-2</a:Value>
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes>
<a:EntityState i:nil="true"/>
<a:FormattedValues/>
<a:Id>f450b346-69e7-e411-80d4-0050568c1f85</a:Id>
<a:LogicalName>customers</a:LogicalName>
<a:RelatedEntities/>
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true"/>
<a:RequestName>Update</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
Can anyone help me on this?
Thanks in advance for your support?
Ashish Mishra
Upvotes: 1
Views: 842
Reputation: 4111
The Update request can only target a single record. You will first need to retrieve the entities that match your criteria and then you can loop through the results and issue Update requests for each one using their ID.
Upvotes: 1