Announcements
Hi all
This seems like it should've been done a thousand times, yet I'm not finding any good examples? Or maybe I'm searching for the wrong things...
Essentially, I execute aExecuteQuickFind request, and need to parse the results into usable JavaScript objects representing the returned entity records.
Request:
<request xmlns:a="schemas.microsoft.com/.../Contracts"> <a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic"> <a:KeyValuePairOfstringanyType> <b:key>SearchText</b:key> <b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">test</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>EntityNames</b:key> <b:value i:type="c:ArrayOfstring" xmlns:c="schemas.microsoft.com/.../Arrays"> <c:string>account</c:string> <c:string>contact</c:string> </b:value> </a:KeyValuePairOfstringanyType> </a:Parameters> <a:RequestId i:nil="true" /> <a:RequestName>ExecuteQuickFind</a:RequestName> </request>
And I get back the following response:
<s:Body> <ExecuteResponse xmlns="schemas.microsoft.com/.../Services"> <ExecuteResult xmlns:a="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance"> <a:ResponseName>ExecuteQuickFind</a:ResponseName> <a:Results xmlns:b="schemas.datacontract.org/.../System.Collections.Generic"> <a:KeyValuePairOfstringanyType> <b:key>Result</b:key> <b:value i:type="a:QuickFindResultCollection"> <a:QuickFindResult> <a:Data> <a:Entities/> <a:EntityName>account</a:EntityName> <a:MinActiveRowVersion>-1</a:MinActiveRowVersion> <a:MoreRecords>false</a:MoreRecords> <a:PagingCookie/> <a:TotalRecordCount>-1</a:TotalRecordCount> <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded> </a:Data> <a:ErrorCode>0</a:ErrorCode> <a:QueryColumnSet xmlns:c="schemas.microsoft.com/.../Arrays" i:nil="true"/> </a:QuickFindResult> <a:QuickFindResult> <a:Data> <a:Entities> <a:Entity> <a:Attributes> <a:KeyValuePairOfstringanyType> <b:key>fullname</b:key> <b:value xmlns:c="www.w3.org/.../XMLSchema" i:type="c:string">A TEST</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>emailaddress1</b:key> <b:value xmlns:c="www.w3.org/.../XMLSchema" i:type="c:string">atest@testemail.com</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>contactid</b:key> <b:value xmlns:c="schemas.microsoft.com/.../Serialization" i:type="c:guid">********-****-****-****-************</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>entityimage_url</b:key> <b:value xmlns:c="www.w3.org/.../XMLSchema" i:type="c:string">/Image/download.aspx?Entity=contact&Attribute=entityimage&Id=********-****-****-****-************&Timestamp=636419355553591067</b:value> </a:KeyValuePairOfstringanyType> </a:Attributes> <a:EntityState i:nil="true"/> <a:FormattedValues/> <a:Id>********-****-****-****-************</a:Id> <a:KeyAttributes xmlns:c="schemas.microsoft.com/.../Contracts"/> <a:LogicalName>contact</a:LogicalName> <a:RelatedEntities/> <a:RowVersion i:nil="true"/> </a:Entity> <a:Entity> <a:Attributes> <a:KeyValuePairOfstringanyType> <b:key>fullname</b:key> <b:value xmlns:c="www.w3.org/.../XMLSchema" i:type="c:string">Another TEST</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>emailaddress1</b:key> <b:value xmlns:c="www.w3.org/.../XMLSchema" i:type="c:string">anothertest@testemail.com</b:value> </a:KeyValuePairOfstringanyType> <a:KeyValuePairOfstringanyType> <b:key>contactid</b:key> <b:value xmlns:c="schemas.microsoft.com/.../Serialization" i:type="c:guid">********-****-****-****-************</b:value> </a:KeyValuePairOfstringanyType> </a:Attributes> <a:EntityState i:nil="true"/> <a:FormattedValues/> <a:Id>********-****-****-****-************</a:Id> <a:KeyAttributes xmlns:c="schemas.microsoft.com/.../Contracts"/> <a:LogicalName>contact</a:LogicalName> <a:RelatedEntities/> <a:RowVersion i:nil="true"/> </a:Entity> </a:Entities> <a:EntityName>contact</a:EntityName> <a:MinActiveRowVersion>-1</a:MinActiveRowVersion> <a:MoreRecords>true</a:MoreRecords> <a:PagingCookie>***Removed***</a:PagingCookie> <a:TotalRecordCount>-1</a:TotalRecordCount> <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded> </a:Data> <a:ErrorCode>0</a:ErrorCode> <a:QueryColumnSet xmlns:c="schemas.microsoft.com/.../Arrays" i:nil="true"/> </a:QuickFindResult> </b:value> </a:KeyValuePairOfstringanyType> </a:Results> </ExecuteResult> </ExecuteResponse> </s:Body>
I need some representation of the return "account" and "contact" records that preserves their data types as much as possible.
Any help would be much appreciated!
James
*This post is locked for comments
Thanks Aric - this would be first prize, but I can't see how to do the ExecuteQuickFind using WebAPI? Could you provide a link or an example? I did look into using the SaveQuery via WebAPI, but I can't see how to pass any additional parameters (e.g. the search term) to them?
Why don't you use CRM 2016 webapi? This is the way you should be querying CRM data now.
André Arnaud de Cal...
294,110
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator