Update data in CRM 2011 using Execute - UpdateRequest + soap XML

最后都变了- 提交于 2019-12-11 12:31:19

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/31066528/update-data-in-crm-2011-using-execute-updaterequest-soap-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!