Search code examples
xmlsoapdynamics-crmdynamics-crm-2015

Serializing entity collections in JavaScript to send via SOAP call


Currently trying to serialize an EntityCollection in order to send selected records to a custom action through client side interaction. Right now, sending the EntityCollection itself has been troublesome. Any ideas?


Solution

  • Found out how it is expecting to be serialized, in case anyone else has issues with this in the future.

    <a:KeyValuePairOfstringanyType>
              <b:key>BusinessEntityCollection</b:key>
              <b:value i:type="a:EntityCollection">
                <a:Entities>
                  <a:Entity>
                    <a:Attributes>
                      <a:KeyValuePairOfstringanyType>
                        <b:key>webresourceid</b:key>
                        <b:value i:type="z:guid">02fe0b47-8800-e511-80ef-c4346bada558</b:value>
                      </a:KeyValuePairOfstringanyType>
                      <a:KeyValuePairOfstringanyType>
                        <b:key>name</b:key>
                        <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">ryr_formexperiment.crmform.min.js</b:value>
                      </a:KeyValuePairOfstringanyType>
                      <a:KeyValuePairOfstringanyType>
                        <b:key>content</b:key>
                        <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">Ly9yeXJfZm9ybWV4cGVyaW1lbnQuY3JtZm9ybS5taW4uanM=</b:value>
                      </a:KeyValuePairOfstringanyType>
                      <a:KeyValuePairOfstringanyType>
                        <b:key>webresourcetype</b:key>
                        <b:value i:type="a:OptionSetValue">
                          <a:Value>3</a:Value>
                        </b:value>
                      </a:KeyValuePairOfstringanyType>
                    </a:Attributes>
                    <a:EntityState i:nil="true" />
                    <a:FormattedValues>
                      <a:KeyValuePairOfstringstring>
                        <b:key>webresourcetype</b:key>
                        <b:value>Script (JScript)</b:value>
                      </a:KeyValuePairOfstringstring>
                    </a:FormattedValues>
                    <a:Id>02fe0b47-8800-e511-80ef-c4346bada558</a:Id>
                    <a:KeyAttributes xmlns:c="http://schemas.microsoft.com/xrm/7.1/Contracts" />
                    <a:LogicalName>webresource</a:LogicalName>
                    <a:RelatedEntities />
                    <a:RowVersion>1308124</a:RowVersion>
                  </a:Entity>
                </a:Entities>
                <a:EntityName>webresource</a:EntityName>
                <a:MinActiveRowVersion>-1</a:MinActiveRowVersion>
                <a:MoreRecords>false</a:MoreRecords>
                <a:PagingCookie><cookie page="1"><webresourceid last="{02FE0B47-8800-E511-80EF-C4346BADA558}" first="{02FE0B47-8800-E511-80EF-C4346BADA558}" /></cookie></a:PagingCookie>
                <a:TotalRecordCount>-1</a:TotalRecordCount>
                <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded>
              </b:value>
            </a:KeyValuePairOfstringanyType>