web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

SOAP not create record if OptionSetValue pass

(0) ShareShare
ReportReport
Posted on by 810

Hi,

I am trying to create opportunity and we have lead type global option set is there using SOAP XML.

We are able to create record if we don't pass optionset in xml but if we pass optionset it throw error

"Message: A validation error occurred.  The value of 'new_leadtype' on record of type 'opportunity' is outside the valid range., ErrorCode: -2147204326"

above has option which doesn't have 0 (zero) value. 

Here is weird behavior, I have second attribute with global optionset type which has value "0" as option (not as text) if I create opportunity with second optionset. SOAP get parse and record created in CRM. but it is always set as a "0" value regardless whatever value you have passed.

But everything works fine from UI.

*This post is locked for comments

I have the same question (0)
  • Dhaval mistry Profile Picture
    810 on at

    Trace log after enable trace on server.

    Crm Exception: Message: A validation error occurred.  The value of 'botw_customertypecode' on record of type 'botw_referral' is outside the valid range., ErrorCode: -2147204326, InnerException: Microsoft.Crm.ObjectModel.CrmPicklistAttributeValidationException: A validation error occurred.  The value of 'botw_customertypecode' on record of type 'botw_referral' is outside the valid range.

      at Microsoft.Crm.ObjectModel.PicklistAttributeValidator.Validate(Entity entity, KeyValuePair`2 property, AttributeMetadata attributeMetadata, ExecutionContext platformContext)

      at Microsoft.Crm.ObjectModel.AttributeValidationPlugin.ValidateAttributeValue(Entity entity, KeyValuePair`2 property, AttributeMetadata attributeMetadata, ExecutionContext context, Entity parentEntity)

      at Microsoft.Crm.ObjectModel.AttributeValidationPlugin.PerformValidation(Entity entity, EntityMetadata entityMetadata, ExecutionContext platformContext, Entity parentEntity)

      at Microsoft.Crm.ObjectModel.AttributeValidationPlugin.Execute(IServiceProvider serviceProvider)

      at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)

      at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

    Microsoft.Crm.ObjectModel.PicklistAttributeValidator.Validate method creating issue.

  • Dhaval mistry Profile Picture
    810 on at

    i have tested with CRM 2015 vanilla version below is XML using SOAP UI but i am facing same error.

    Microsoft.Crm.ObjectModel.PicklistAttributeValidator.Validate

    <?xml version="1.0" encoding="utf-8"?>

    <soapenv:Envelope

    xmlns:soapenv="schemas.xmlsoap.org/.../&quot;

    xmlns:ser="schemas.microsoft.com/.../Services&quot;

    xmlns:con="schemas.microsoft.com/.../Contracts&quot;

    xmlns:sys="schemas.datacontract.org/.../System.Collections.Generic&quot;

    xmlns:i="www.w3.org/.../XMLSchema-instance&quot;

    xmlns:c="www.w3.org/.../XMLSchema&quot;>

     <soapenv:Body>

       <ser:Create>

         <ser:entity>

           <con:Attributes>

             <!-- STRING DATATYPE-->

             <con:KeyValuePairOfstringanyType>

               <sys:key>name</sys:key>

               <sys:value i:type="c:string">DM Testing 3</sys:value>

             </con:KeyValuePairOfstringanyType>

             <!-- LOOKUP DATATYPE-->

             <con:KeyValuePairOfstringanyType>

               <sys:key>parentaccountid</sys:key>

               <sys:value i:type="con:EntityReference">

                 <con:Id>B0A8CF24-1F9B-E511-80DF-00155DCBB69B</con:Id>

                 <con:LogicalName>account</con:LogicalName>

                 <con:Name i:nil="true"/>

               </sys:value>

             </con:KeyValuePairOfstringanyType>

             <!-- DATETIME DATATYPE-->

             <con:KeyValuePairOfstringanyType>

               <sys:key>estimatedclosedate</sys:key>

               <sys:value i:type="c:dateTime">2015-12-12T09:56:00</sys:value>

             </con:KeyValuePairOfstringanyType>

             <!-- MONEY (CURRENCY) DATATYPE-->

             <con:KeyValuePairOfstringanyType>

               <sys:key>discountamount</sys:key>

               <sys:value i:type="con:Money">

                 <con:value>1000</con:value>

               </sys:value>

             </con:KeyValuePairOfstringanyType>

             <!-- OPTIONSET DATATYPE-->

             <con:KeyValuePairOfstringanyType>

               <sys:key>new_customertype</sys:key>

               <sys:value i:type="con:OptionSetValue">

                 <con:value>100000000</con:value>

               </sys:value>

             </con:KeyValuePairOfstringanyType>

             <!-- TWO OPTIONS SET DATATYPE-->

            <!-- <con:KeyValuePairOfstringanyType>

               <sys:key>cbg_cancellableswap</sys:key>

               <sys:value i:type="c:boolean">false</sys:value>

             </con:KeyValuePairOfstringanyType>-->

           </con:Attributes>

           <con:LogicalName>opportunity</con:LogicalName>

         </ser:entity>

       </ser:Create>

     </soapenv:Body>

    </soapenv:Envelope>

  • Aram Adnan Profile Picture
    375 on at
  • Verified answer
    Dhaval mistry Profile Picture
    810 on at

    Guys thanks for the help,

    Below is the solution, OptionSet is CRM data type so we need to make option value tag should be <sys:Value> capital "V". I was using small v.

          <con:KeyValuePairOfstringanyType>

              <sys:key>cbg_cancellableswap</sys:key>

              <sys:value i:type="c:boolean">false</sys:value>

            </con:KeyValuePairOfstringanyType>-->

          </con:Attributes>

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans