The CRM has some customized option sets, for example, Salutation option set is defined for Contact entity. I need to get values of this option set when creating or updating contacts. I tried to use RetrieveOptionSet
request to get the option set values as below:
SOAP action to use http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute
SOAP request body
<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:RetrieveOptionSetRequest" 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>MetadataId</b:key>
<b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>RetrieveAsIfPublished</b:key>
<b:value i:type="c:boolean" xmlns:c="http://www.w3.org/2001/XMLSchema">true</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">my_type</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true" />
<a:RequestName>RetrieveOptionSet</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
The problem is that I can only use this request to get global option sets, but for customized option sets, this request just returns a not found error.
Does anyone knows how to get customized option set values?
EDIT: I'm using Java client to access Dynamics CRM web service. This is the final SOAP request body I used to successfully get option set values.
<s:Envelope>
<s:Body>
<Execute>
<request i:type="a:RetrieveAttributeRequest">
<a:Parameters>
<a:KeyValuePairOfstringanyType>
<b:key>MetadataId</b:key>
<b:value i:type="c:guid">00000000-0000-0000-0000-000000000000</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>RetrieveAsIfPublished</b:key>
<b:value i:type="c:boolean">true</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>EntityLogicalName</b:key>
<b:value i:type="c:string">contact</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>LogicalName</b:key>
<b:value i:type="c:string">my_type</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true"/>
<a:RequestName>RetrieveAttribute</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
The sample code in this page gave me useful information.