Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Virginia Neal
    Value not found for element DataValue - Setting a Custom...
    Topic posted June 2, 2011 by Virginia NealGreen Ribbon: 100+ Points, last edited October 29, 2011 
    1901 Views, 18 Comments
    Title:
    Value not found for element DataValue - Setting a Custom Field When Creating an Incident
    Content:

     Using RightNow Connect I am sending an XML Object to create an Incident.  If the XML object does NOT contain any custom fields the incident is created and all is well.  As soon as I try add an element for CustomFields, the message failes with a status code 500 and the error message "RightNowSyncService|urn:wsdl.ws.rightnow.com/v1 failed Value not found for element DataValue which has minOccurs = 1 Failed in constructing object Incident : NULL input can not be deserialized Failed in setting value for element CustomFields array position 0 of object Incident Failed in constructing object CreateMsg : NULL input can not be deserialized Failed in setting value for element RNObjects array position 0 of object CreateMsg Failure in setting value for object Create element Create of type messages_ws_rightnow_com_v1::CreateMsg NULL returned from the Create deserializer due to missing or invalid XML"

    I have tried all kinds of variations when building the XML and nothing seems to work.  Can someone please take a look at the XML and see if you can spot what I might be doing wrong?

    The code block contains all the XML, but the code below is the what is causing the error:

                <s1:CustomFields>
                    <s1:GenericField name="Owner">
                       <s1:DataValue>
                        <s2:IDValue id="#owner#" />
                       </s1:DataValue>
                    </s1:GenericField>
                </s1:CustomFields>

    When the snippet above is included in the XML my attempt to create an incident fails.  When the snippet is NOT included, the incident is created just fine.

    The custom field I am trying to populate is named Owner and it contains an ID.  The value being passed is set to 80.  The attached image shows the value being passed. 

    Been fighting with this for quite awhile, so any help would be appreciated.

    Thanks

    Image:
    Code Snippet:

    Comment

    • Daniel Andrews

      Hi Virginia,

       

      How are you generating that xml for the CustomField? Nesting the GenericField within the CustomField is incorrect - CustomFields are GenericFields. Take the name you have in the GenericField tag, put that in the CustomField tag, and then remove the GenericField tags. Give that a try and let me know if that works.

       

      Daniel

    • Daniel Andrews

      Just to be clear, what I mean is to try

                  <s1:CustomFields name="Owner">
                       <s1:DataValue>
                          <s2:IDValue id="#owner#" />
                       </s1:DataValue>
                  </s1:CustomFields>

    • Virginia Neal

      Thanks for the suggestion Daniel.  I gave it a try, but unfortunately that did not resolve the problem.  I still receive the exact same error message.

    • Daniel Andrews

      On a second look it appears that your namespaces aren't configured properly to use DataValue - DataValue belongs to the generic namespace (urn:generic.ws.rightnow.com/v1) , as does IDValue

    • Daniel Andrews

      I suggest adding 

       

      xmlns:s3="urn:generic.ws.rightnow.com/v1"

       

      and then

                 <s1:CustomFields name="Owner">
                       <s3:DataValue>
                          <s3:IDValue id="#owner#" />
                       </s3:DataValue>
                  </s1:CustomFields>

    • Virginia Neal

      That makes sense and trying it did produce a different error message.  Here is what I did:

      Added the generic namespace as s3

           <s0:Create xmlns:s0="urn:messages.ws.rightnow.com/v1"
                 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s2="urn:base.ws.rightnow.com/v1" xmlns:s1="urn:objects.ws.rightnow.com/v1" xmlns:s3="urn:generic.ws.rightnow.com/v1">

      Then changed the code to

             <s1:CustomFields name="Owner">
                       <s3:DataValue>
                          <s3:IDValue id="#owner#" />
                       </s3:DataValue>
                  </s1:CustomFields>

      The new error message is "SenderCould not find property for given key: Owner While processing Incident->CustomFields(rng_v1::GenericField[]).UNKNOWN_EXCEPTIONCould not find property for given key: Owner While processing Incident->CustomFields(rng_v1::GenericField[]). "

      Owner is a custom field under Incident.

    • Daniel Andrews

      Hi again,

       

      I forgot to point out that custom field names in the xml must be prepended with "c$" (and it's case-sensitive). We mask this in the client but at the soap level your custom field name, in this case, will be "c$Owner".

       

      Also, what is the Owner field's type? Is it an integer, a menu, a boolean, or a named ID? Referencing IDValue will not work because in CWS-SOAP, foreign keys for objects are referenced with NamedIDs. I'll post some sample code shortly to show you what I mean.

       

    • Daniel Andrews

      If your id is a foriegn key, then you'll use named IDs to lookup the owner.

       

      Here's what I mean:

      *sorry for the poor formatting

      <rno:CustomFields dataType='NAMED_ID' name='c$Owner'>

      <rng:DataValue>

      <rng:NamedIDValue>

                    <rnb:ID id='#owner#' />           

      </rng:NamedIDValue>         

       </rng:DataValue>

      </rno:CustomFields>

       

      If your customfield is of type Integer, then you must set an IntegerValue within your datavalue tags:

               <rno:CustomFields dataType='INTEGER' name='c$Owner'>

                 <rng:DataValue>

                   <rng:IntegerValue>#owner#</rng:IntegerValue>

                 </rng:DataValue>

               </rno:CustomFields>

       

      Note that you'll need to change the namespaces on these tags

       

    • Virginia Neal

       Neither example above worked, but that is probably because I believe the field type is MENU (see attached image).

      Given that I am dealing with a menu type, how would I set the value>

    • Daniel Andrews

      If c$Owner is a menu type, then the named id way should work. I'm going try your xml out and look into this further.

    • Virginia Neal

       Thank you!!

      The most current version is:

                  <s1:CustomFields dataType="NAMED_ID" name="c$Owner">
                    <s3:DataValue>
                        <s3:NamedIDValue>
                        <s3:ID id='#owner#' />          
                  </s3:NamedIDValue>  
                    </s3:DataValue>
                  </s1:CustomFields>

      I have attached a file with the full xml.

      The error message has changed when sending this message.  I am now getting the following error:

      SenderData element in the Message is NULLRightNowSyncService|urn:wsdl.ws.rightnow.com/v1 failed Found out-of-order or unrecognized node ID|urn:generic.ws.rightnow.com/v1 while parsing node of type NamedID|urn:base.ws.rightnow.com/v1 Failure in setting value for object DataValue_choice_type element NamedIDValue of type base_ws_rightnow_com_v1::NamedID Failure in parsing choice indicator in DataValue element Failure in setting value for object GenericField element DataValue of type generic_ws_rightnow_com_v1::DataValue Failed in constructing object Incident : NULL input can not be deserialized Failed in setting value for element CustomFields array position 0 of object Incident Failed in constructing object CreateMsg : NULL input can not be deserialized Failed in setting value for element RNObjects array position 0 of object CreateMsg Failure in setting value for object Create element Create of type messages_ws_rightnow_com_v1::CreateMsg NULL returned from the Create deserializer due to missing or invalid XML

       

    • Daniel Andrews

      The namespace on ID is incorrect - it needs to be s2 - give that a try and let me know what you get

    • Virginia Neal

      Which field(s) should have the s2? 

      I have

      xmlns:s1="urn:objects.ws.rightnow.com/v1"
      xmlns:s2="urn:base.ws.rightnow.com/v1"
      xmlns:s3="urn:generic.ws.rightnow.com/v1

                  <s1:CustomFields dataType="NAMED_ID" name="c$Owner">
                    <s3:DataValue>
                        <s3:NamedIDValue>
                        <s3:ID id='#owner#' />          
                    </s3:NamedIDValue>  
                    </s3:DataValue>
                  </s1:CustomFields>

    • Daniel Andrews

      ID is of the base type, so you need the base namespace attached to it, like this:

                <s1:CustomFields dataType="NAMED_ID" name="c$Owner">
                    <s3:DataValue>
                       <s3:NamedIDValue>
                        <s2:ID id='#owner#' />        
                      </s3:NamedIDValue>  
                    </s3:DataValue>
                  </s1:CustomFields>

    • Virginia Neal

       Just tried that - still no go. 

      Error - SenderCould not find property for given key: Owner While processing Incident->CustomFields(rng_v1::GenericField[]).UNKNOWN_EXCEPTIONCould not find property for given key: Owner While processing Incident->CustomFields(rng_v1::GenericField[]).