Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Processing the results of a SOAP Execute message into JavaScript objects representing the returned entities

Posted on by

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&amp;Attribute=entityimage&amp;Id=********-****-****-****-************&amp;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

  • James Profile Picture
    James on at
    RE: Processing the results of a SOAP Execute message into JavaScript objects representing the returned entities

    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?

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Processing the results of a SOAP Execute message into JavaScript objects representing the returned entities

    Why don't you use CRM 2016 webapi? This is the way you should be querying CRM data now.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans