I am connecting to Dynamics CRM 2011 Online using PHP and SOAP and have come across an issue. The following RetrieveMultiple ignores my criteria and returns all records.
All I want is any contacts that have '[email protected]' as their email address.
Could someone tell me what is wrong with my Criteria/Condition below?
Thanks!
<RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
<query xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" i:type="b:QueryExpression">
<b:ColumnSet>
<b:AllColumns>false</b:AllColumns>
<b:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:string>firstname</c:string>
</b:Columns>
</b:ColumnSet>
<b:Criteria>
<b:Conditions>
<b:Condition>
<b:AttributeName>emailaddress1</b:AttributeName>
<b:Operator>Equal</b:Operator>
<b:Values>
<b:Value i:type="xsd:string">[email protected]</b:Value>
</b:Values>
</b:Condition>
</b:Conditions>
<b:FilterOperator>And</b:FilterOperator>
<b:Filters />
</b:Criteria>
<b:Distinct>false</b:Distinct>
<b:EntityName>contact</b:EntityName>
<b:LinkEntities />
<b:PageInfo>
<b:Count>250</b:Count>
<b:PageNumber>1</b:PageNumber>
<b:PagingCookie i:nil="true" />
<b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>
</b:PageInfo>
</query>
</RetrieveMultiple>
Try to use following SOAP format:
<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:RetrieveMultipleRequest" 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>Query</b:key>
<b:value i:type="a:QueryExpression">
<a:ColumnSet>
<a:AllColumns>false</a:AllColumns>
<a:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:string>firstname</c:string>
</a:Columns>
</a:ColumnSet>
<a:Criteria>
<a:Conditions>
<a:ConditionExpression>
<a:AttributeName>emailaddress1</a:AttributeName>
<a:Operator>Equal</a:Operator>
<a:Values xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:anyType i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">[email protected]</c:anyType>
</a:Values>
</a:ConditionExpression>
</a:Conditions>
<a:FilterOperator>And</a:FilterOperator>
<a:Filters />
<a:IsQuickFindFilter>false</a:IsQuickFindFilter>
</a:Criteria>
<a:Distinct>false</a:Distinct>
<a:EntityName>contact</a:EntityName>
<a:LinkEntities />
<a:Orders />
<a:PageInfo>
<a:Count>0</a:Count>
<a:PageNumber>0</a:PageNumber>
<a:PagingCookie i:nil="true" />
<a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>
</a:PageInfo>
<a:NoLock>false</a:NoLock>
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true" />
<a:RequestName>RetrieveMultiple</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
BTW. you can use SOAPLogger where was located in SDK\samplecode\cs\client\soaplogger to get the correct SOAP expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With