locked
How do I add data to boolean fields when creating a contact through the SOAP api? RRS feed

  • Question

  • I'm manually generating the XML to create a contact, and I'm able to successfully add a contact with fields like firstname, lastname, emailaddress1, etc.

    However, for many of the field types, like boolean or OptionSetValue, I am unable to set. I get back an error with the message "There was an error deserializing the object of type Microsoft.Xrm.Sdk.OrganizationRequest. The prefix 'c' is not defined."

    I'm assuming we aren't formatting these key/value pairs correctly, but am unable to find an example of exactly how they should be formatted.

    Currently I'm trying something along the lines of:

    <a:KeyValuePairOfstringanyType>
      <b:key>donotsendmm</b:key>
      <c:value i:type='d:boolean' xmlns:d='http://www.w3.org/2001/XMLSchema'>1</c:value></a:KeyValuePairOfstringanyType>

    (I've also tried true, True, "Send", etc, to no avail.)

    What should the xml for this look like?

    Thanks!


    • Edited by j_mallard Friday, January 24, 2014 2:49 AM
    Friday, January 24, 2014 2:48 AM

Answers

  • Hi,

    We usually use REST to create/update record through javascript.

    If you really need to use SOAP, check out SOAP Logger (\sdk\samplecode\cs\client\soaplogger). Write your code to create Contact with Boolean value there, run it and you will get the SOAP XML request. Then you will know how to fix your issue.

    Hope it helps.

    • Marked as answer by j_mallard Friday, January 24, 2014 6:11 AM
    Friday, January 24, 2014 3:06 AM

All replies

  • Hi,

    We usually use REST to create/update record through javascript.

    If you really need to use SOAP, check out SOAP Logger (\sdk\samplecode\cs\client\soaplogger). Write your code to create Contact with Boolean value there, run it and you will get the SOAP XML request. Then you will know how to fix your issue.

    Hope it helps.

    • Marked as answer by j_mallard Friday, January 24, 2014 6:11 AM
    Friday, January 24, 2014 3:06 AM
  • Please ensure that field name is correct, if donotsendmm is custom field then field name would be new_donotsendmm.

    and pass the field value true instead of 1.


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    Friday, January 24, 2014 4:31 AM
  • It was a silly copy/paste error: c: value should be b: value, and d:boolean should be c:boolean. Works now. Thanks for the SOAP logger tool, though, it may be helpful in the future.
    Friday, January 24, 2014 6:12 AM