Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

SOAP Organization Service Execute Create New account with OptionSetValueCollection - error Cannot insert the value NULL into column 'SelectedOptionValues'

Posted on by

Hello folks,

do you have me maybe a tipp what is wrong in my POST SOAP request if I am trying to create a new account via the IOrganizationService/Execute? I want to fill in only two fields on the newly created account:

a. Standard field: name

b. Custom field: ap_accountrole that is a multiOptionSet field (supported from version 9.0), here you can see more about the field:

CRM_5F00_9.0_5F00_OrgServ_5F00_Create_5F00_Account_5F00_MultiOptionSet_5F00_FieldDetails.png


but I always get the following error message as Response:

Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.'
The CRM version is 1710 9.1.0.876 online

Do you have any idea why it is not working correctly and as expected? Is the syntax wrong? Does the old Org.Service not longer support this new feature of CRM 9.x?

I'd really appreciate any hints from the community.

Thank you in advance!

Regards,

Norbert

My SOAP Request was:

POST: <validName>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc/web
Header:
Authorization	Bearer <validToken>
SOAPAction	schemas.microsoft.com/.../Execute
Content-Type	text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
  <s:Body>
    <Execute xmlns="schemas.microsoft.com/.../Services" xmlns:i="www.w3.org/.../XMLSchema-instance">
      <request i:type="a:CreateRequest" xmlns:a="schemas.microsoft.com/.../Contracts">
        <a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
          <a:KeyValuePairOfstringanyType>
            <b:key>Target</b:key>
            <b:value i:type="a:Entity">
              <a:Attributes>
                <a:KeyValuePairOfstringanyType>
                  <b:key>name</b:key>
                  <b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Account_CPQ_Test_20181209194131</b:value>
                </a:KeyValuePairOfstringanyType>
                <a:KeyValuePairOfstringanyType>
                  <b:key>ap_accountrole</b:key>
                  <b:value i:type="c:OptionSetValueCollection" xmlns:c="schemas.microsoft.com/.../Contracts">
                    <c:OptionSetValue>
                      <a:Value>778210000</a:Value>
                    </c:OptionSetValue>
                  </b:value>
                </a:KeyValuePairOfstringanyType>
              </a:Attributes>
              <a:EntityState i:nil="true" />
              <a:FormattedValues xmlns:b="schemas.datacontract.org/.../System.Collections.Generic" />
              <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
              <a:LogicalName>account</a:LogicalName>
              <a:RelatedEntities />
            </b:value>
          </a:KeyValuePairOfstringanyType>
        </a:Parameters>
        <a:RequestId i:nil="true" />
        <a:RequestName>Create</a:RequestName>
      </request>
    </Execute>
  </s:Body>
</s:Envelope>

And the response with error message looks:

Header:
x-ms-service-request-id	33c367c2-effa-4fd9-a45e-30511f15c8a0
REQ_ID	33c367c2-effa-4fd9-a45e-30511f15c8a0
Content-Length	14462
Cache-Control	private
Content-Type	text/xml; charset=utf-8
Date	Thu, 13 Dec 2018 10:11:11 GMT
Set-Cookie	ApplicationGatewayAffinity=0dba0a79351f5b72d2eea63a5bcb63ad64f2c424fed5c36a5468a13cb6f69a5b;Path=/;Domain=<OrgName>.api.crm4.dynamics.com
Server	

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
  <s:Body>
    <s:Fault>
      <faultcode>s:Client</faultcode>
      <faultstring xml:lang="en-US">Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.'</faultstring>
      <detail>
        <OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
          <ActivityId>45beaf84-edb0-4cab-aa54-f8b5b483a882</ActivityId>
          <ErrorCode>-2147204784</ErrorCode>
          <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic">
            <KeyValuePairOfstringanyType>
              <a:key>ApiExceptionSourceKey</a:key>
              <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">Plugin/Microsoft.Crm.Common.ObjectModel.AccountService</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiOriginalExceptionKey</a:key>
              <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">Microsoft.Crm.CrmException: Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.' ---&gt; Microsoft.Crm.CrmException: Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.' ---&gt; System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.LockConnectionAndExecuteMethod[TResult](IDbConnection connection, Func`1 executeMethod)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.&lt;&gt;c__DisplayClass110_0.&lt;InternalExecuteNonQuery&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.Platform.Server.DataEngine.SqlDataAccessManager.&lt;&gt;c__DisplayClass2_0.&lt;ExecuteNonQuery&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.BusinessEntities.MultiSelectOptionValuesTrigger.DoCreate(Guid id, MultiSelectOptionsInfo info)
   at Microsoft.Crm.BusinessEntities.MultiSelectOptionValuesTrigger.Create(Guid id)
   at Microsoft.Crm.BusinessEntities.TriggersExtension.ExecuteTriggers(BusinessEntity entity, ArrayList triggers, OperationType operationType)
   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.PostCreateEventHandler.Invoke(Object sender, ExtensionEventArgs e)
   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.&lt;&gt;c__DisplayClass167_0.&lt;Create&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.Common.ObjectModel.AccountService.Create(IBusinessEntity entity, ExecutionContext context)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.Pipeline.&lt;&gt;c__DisplayClass2_1.&lt;Execute&gt;b__0()</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiStepKey</a:key>
              <a:value i:type="b:guid" xmlns:b="schemas.microsoft.com/.../Serialization">ffc9bb1b-ea3e-db11-86a7-000a3a5473e8</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiDepthKey</a:key>
              <a:value i:type="b:int" xmlns:b="www.w3.org/.../XMLSchema">1</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiActivityIdKey</a:key>
              <a:value i:type="b:guid" xmlns:b="schemas.microsoft.com/.../Serialization">45beaf84-edb0-4cab-aa54-f8b5b483a882</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiPluginSolutionNameKey</a:key>
              <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">System</a:value>
            </KeyValuePairOfstringanyType>
            <KeyValuePairOfstringanyType>
              <a:key>ApiStepSolutionNameKey</a:key>
              <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">System</a:value>
            </KeyValuePairOfstringanyType>
          </ErrorDetails>
          <Message>Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.'</Message>
          <Timestamp>2018-12-13T10:11:11.3721858Z</Timestamp>
          <ExceptionRetriable>false</ExceptionRetriable>
          <ExceptionSource i:nil="true" />
          <InnerFault>
            <ActivityId>45beaf84-edb0-4cab-aa54-f8b5b483a882</ActivityId>
            <ErrorCode>-2147204784</ErrorCode>
            <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
            <Message>Sql error: 'Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.'</Message>
            <Timestamp>2018-12-13T10:11:11.3721858Z</Timestamp>
            <ExceptionRetriable>false</ExceptionRetriable>
            <ExceptionSource i:nil="true" />
            <InnerFault>
              <ActivityId>45beaf84-edb0-4cab-aa54-f8b5b483a882</ActivityId>
              <ErrorCode>-2147220970</ErrorCode>
              <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
              <Message>Exception output:: System.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.LockConnectionAndExecuteMethod[TResult](IDbConnection connection, Func`1 executeMethod)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.&lt;&gt;c__DisplayClass110_0.&lt;InternalExecuteNonQuery&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.Platform.Server.DataEngine.SqlDataAccessManager.&lt;&gt;c__DisplayClass2_0.&lt;ExecuteNonQuery&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.BusinessEntities.MultiSelectOptionValuesTrigger.DoCreate(Guid id, MultiSelectOptionsInfo info)
   at Microsoft.Crm.BusinessEntities.MultiSelectOptionValuesTrigger.Create(Guid id)
   at Microsoft.Crm.BusinessEntities.TriggersExtension.ExecuteTriggers(BusinessEntity entity, ArrayList triggers, OperationType operationType)
   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.PostCreateEventHandler.Invoke(Object sender, ExtensionEventArgs e)
   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.&lt;&gt;c__DisplayClass167_0.&lt;Create&gt;b__0()
   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
   at Microsoft.Crm.Common.ObjectModel.AccountService.Create(IBusinessEntity entity, ExecutionContext context)
ClientConnectionId:1ada3058-636e-40fe-b05e-2e96427c89c8
Error Number:515,State:2,Class:16
ClientConnectionId before routing:9dd1a11a-f8f4-4b97-9c05-a8a636eb8fbf
Routing Destination:dcc1f4abba56.tr18.northeurope1-a.worker.database.windows.net,11138
Error(s) details: 
Class: 0x10
LineNumber: 1
Message: Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
Number: 515
Procedure: 
Server: dcc1f4abba56.tr18.northeurope1-a.worker.database.windows.net,11138
Source: .Net SqlClient Data Provider
State: 2
ToString(): System.Data.SqlClient.SqlError: Cannot insert the value NULL into column 'SelectedOptionValues', table 'db_crmcoreemea_20180909_07491506_4bcc.dbo.MultiSelectAttributeOptionValuesBase'; column does not allow nulls. INSERT fails.
--
Class: 0x0
LineNumber: 1
Message: The statement has been terminated.
Number: 3621
Procedure: 
Server: dcc1f4abba56.tr18.northeurope1-a.worker.database.windows.net,11138
Source: .Net SqlClient Data Provider
State: 0
ToString(): System.Data.SqlClient.SqlError: The statement has been terminated.
--
: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #A29A4BCD</Message>
              <Timestamp>2018-12-13T10:11:11.3731844Z</Timestamp>
              <ExceptionRetriable>false</ExceptionRetriable>
              <ExceptionSource i:nil="true" />
              <InnerFault i:nil="true" />
              <OriginalException i:nil="true" />
              <TraceText i:nil="true" />
            </InnerFault>
            <OriginalException i:nil="true" />
            <TraceText i:nil="true" />
          </InnerFault>
          <OriginalException i:nil="true" />
          <TraceText i:nil="true" />
        </OrganizationServiceFault>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>
  • Suggested answer
    a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: SOAP Organization Service Execute Create New account with OptionSetValueCollection - error Cannot insert the value NULL into column 'SelectedOptionValues'

    Hello,

    I'm just curious - why do you need xml? Can you use SDK assemblies?

    Anyway the best way to get proper Xml is to use SoapLogger - www.powerobjects.com/.../microsoft-dynamics-crm-soap-logger-a-tool-that-can-greatly-simplify-writing-http-requests

  • RE: SOAP Organization Service Execute Create New account with OptionSetValueCollection - error Cannot insert the value NULL into column 'SelectedOptionValues'

    Hello Andrew,

    thank you for your answer.

    I tried to first create the account without MultiOptionSetValues and directly after that filling the MultiOptionSet field with values but it does not look like to working because the ap_accountrole field stays still empty. Do you have any idea why is it not filled?

    Create Request:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
      <s:Body>
        <Execute xmlns="schemas.microsoft.com/.../Services" xmlns:i="www.w3.org/.../XMLSchema-instance">
          <request i:type="a:CreateRequest" xmlns:a="schemas.microsoft.com/.../Contracts">
            <a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
              <a:KeyValuePairOfstringanyType>
                <b:key>Target</b:key>
                <b:value i:type="a:Entity">
                  <a:Attributes>
                    <a:KeyValuePairOfstringanyType>
                      <b:key>name</b:key>
                      <b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Account_CPQ_Test_10012019_v1</b:value>
                    </a:KeyValuePairOfstringanyType>
                  </a:Attributes>
                  <a:EntityState i:nil="true" />
                  <a:FormattedValues xmlns:b="schemas.datacontract.org/.../System.Collections.Generic" />
                  <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
                  <a:LogicalName>account</a:LogicalName>
                  <a:RelatedEntities />
                </b:value>
              </a:KeyValuePairOfstringanyType>
            </a:Parameters>
            <a:RequestId i:nil="true" />
            <a:RequestName>Create</a:RequestName>
          </request>
        </Execute>
      </s:Body>
    </s:Envelope>

    Create Response:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
      <s:Body>
        <ExecuteResponse xmlns="schemas.microsoft.com/.../Services">
          <ExecuteResult i:type="a:CreateResponse" xmlns:a="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
            <a:ResponseName>Create</a:ResponseName>
            <a:Results xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
              <a:KeyValuePairOfstringanyType>
                <b:key>id</b:key>
                <b:value i:type="c:guid" xmlns:c="schemas.microsoft.com/.../Serialization">a1d32b2a-e214-e911-a95e-000d3ab3f4dd</b:value>
              </a:KeyValuePairOfstringanyType>
            </a:Results>
          </ExecuteResult>
        </ExecuteResponse>
      </s:Body>
    </s:Envelope>

    Update Request:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
      <s:Body>
        <Execute xmlns="schemas.microsoft.com/.../Services" xmlns:i="www.w3.org/.../XMLSchema-instance">
          <request i:type="a:CreateRequest" xmlns:a="schemas.microsoft.com/.../Contracts">
            <a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
              <a:KeyValuePairOfstringanyType>
                <b:key>Target</b:key>
                <b:value i:type="a:Entity">
                  <a:Attributes>
                    <a:KeyValuePairOfstringanyType>
                      <b:key>name</b:key>
                      <b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Account_CPQ_Test_10012019_v1_updated3</b:value>
                    </a:KeyValuePairOfstringanyType>
                    <a:KeyValuePairOfstringanyType>
                      <b:key>ap_accountrole</b:key>
                      <b:value i:type="c:OptionSetValueCollection" xmlns:c="schemas.microsoft.com/.../Contracts">
                        <c:OptionSetValue>
                          <a:Value>778210001</a:Value>
                        </c:OptionSetValue>
                      </b:value>
                    </a:KeyValuePairOfstringanyType>
                  </a:Attributes>
                  <a:EntityState i:nil="true" />
                  <a:FormattedValues xmlns:b="schemas.datacontract.org/.../System.Collections.Generic" />
                  <a:Id>a1d32b2a-e214-e911-a95e-000d3ab3f4dd</a:Id>
                  <a:LogicalName>account</a:LogicalName>
                  <a:RelatedEntities />
                </b:value>
              </a:KeyValuePairOfstringanyType>
            </a:Parameters>
            <a:RequestId i:nil="true" />
            <a:RequestName>Update</a:RequestName>
          </request>
        </Execute>
      </s:Body>
    </s:Envelope>

    Update Response:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
      <s:Body>
        <ExecuteResponse xmlns="schemas.microsoft.com/.../Services">
          <ExecuteResult i:type="a:CreateResponse" xmlns:a="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
            <a:ResponseName>Update</a:ResponseName>
            <a:Results xmlns:b="schemas.datacontract.org/.../System.Collections.Generic" />
          </ExecuteResult>
        </ExecuteResponse>
      </s:Body>
    </s:Envelope>

    Retrieve Request:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
      <s:Body>
        <Execute xmlns="schemas.microsoft.com/.../Services" xmlns:i="www.w3.org/.../XMLSchema-instance">
          <request i:type="a:RetrieveRequest" xmlns:a="schemas.microsoft.com/.../Contracts">
            <a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
              <a:KeyValuePairOfstringanyType>
                <b:key>Target</b:key>
                <b:value i:type="a:EntityReference">
                  <a:Id>a1d32b2a-e214-e911-a95e-000d3ab3f4dd</a:Id>
                  <a:LogicalName>account</a:LogicalName>
                  <a:Name i:nil="true" />
                </b:value>
              </a:KeyValuePairOfstringanyType>
              <a:KeyValuePairOfstringanyType>
                <b:key>ColumnSet</b:key>
                <b:value i:type="a:ColumnSet">
                  <a:AllColumns>true</a:AllColumns>
                  <a:Columns xmlns:c="schemas.microsoft.com/.../Arrays" />
                </b:value>
              </a:KeyValuePairOfstringanyType>
            </a:Parameters>
            <a:RequestId i:nil="true" />
            <a:RequestName>Retrieve</a:RequestName>
          </request>
        </Execute>
      </s:Body>
    </s:Envelope>

    Retrieve Response:

    It does not contain the field/tag ap_contactrole at all as it is empty and checked one more time on GUI it's really empty.

    I would really appreciate a working example from you!

    Thanks in advance and regards,

    Norbert

  • Verified answer
    a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: SOAP Organization Service Execute Create New account with OptionSetValueCollection - error Cannot insert the value NULL into column 'SelectedOptionValues'

    Hello Norbert,

    There is nothing wrong with your code. Setting the null for Multiselect Optionset  during create will cause an exception. So during the create just don't pass it with other parameters. The same time during Update setting of value to null works fine.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans