Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    s k
    pass custom field when creating incidents
    Topic posted February 12, 2016 by s kRed Ribbon: 250+ Points 
    417 Views, 19 Comments
    Title:
    pass custom field when creating incidents
    Content:

    I create incidents by consuming RightNow WDSL using the xml file.
    But I can't add custom field while creating an incident.
    My xml file:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header>
            <ns7:ClientInfoHeader xmlns:ns7="urn:messages.ws.rightnow.com/v1_2" soapenv:mustUnderstand="0">
                <ns7:AppID>Incident Create</ns7:AppID>
            </ns7:ClientInfoHeader>
            <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                           mustUnderstand="1">
                <wsse:UsernameToken>
                    <wsse:Username>test</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/sdsd">test</wsse:Password>
                </wsse:UsernameToken>
            </wsse:Security>
        </soapenv:Header>
        <soapenv:Body>
            <ns7:Create xmlns:ns7="urn:messages.ws.rightnow.com/v1_2">
                <ns7:RNObjects xmlns:ns4="urn:objects.ws.rightnow.com/v1_2"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:Incident">
                    <ns4:PrimaryContact>
                        <ns4:Contact>
                            <ID xmlns="urn:base.ws.rightnow.com/v1_2" id="325"/>
                        </ns4:Contact>
                    </ns4:PrimaryContact>
                    <ns4:Subject>Conversation</ns4:Subject>
                    <ns4:Threads>
                        <ns4:ThreadList action="add">
                            <ns4:EntryType>
                                <ID xmlns="urn:base.ws.rightnow.com/v1_2" id="1"/>
                            </ns4:EntryType>
                            <ns4:Text>Test</ns4:Text>
                        </ns4:ThreadList>
                    </ns4:Threads>
                    <ns4:CustomFields xmlns:ns2="urn:generic.ws.rightnow.com/v1_3" xsi:type="ns2:GenericObject">
                        <ns2:ObjectType>
                            <ns2:TypeName>IncidentCustomFields</ns2:TypeName>
                        </ns2:ObjectType>
                        <ns2:GenericFields dataType="OBJECT" name="c">
                            <ns2:DataValue>
                                <ns2:ObjectValue xsi:type="ns2:GenericObject">
                                    <ns2:ObjectType>
                                        <ns2:TypeName>IncidentCustomFieldsc</ns2:TypeName>
                                    </ns2:ObjectType>
                                    <ns2:GenericFields dataType="STRING" name="Name of custom field">
                                        <ns2:DataValue>
                                            <ns2:StringValue>Setting Custom Field!</ns2:StringValue>
                                        </ns2:DataValue>
                                    </ns2:GenericFields>
                                </ns2:ObjectValue>
                            </ns2:DataValue>
                        </ns2:GenericFields>
                    </ns4:CustomFields>
                </ns7:RNObjects>
                <ns7:ProcessingOptions>
                    <ns7:SuppressExternalEvents>false</ns7:SuppressExternalEvents>
                    <ns7:SuppressRules>false</ns7:SuppressRules>
                </ns7:ProcessingOptions>
            </ns7:Create>
        </soapenv:Body>
    </soapenv:Envelope>

     

    if I remove following part from xml, incident will be created, BUT I need to add value of this custom field

    <ns4:CustomFields xmlns:ns2="urn:generic.ws.rightnow.com/v1_3" xsi:type="ns2:GenericObject">
    <ns2:ObjectType>
        <ns2:TypeName>IncidentCustomFields</ns2:TypeName>
    </ns2:ObjectType>
    <ns2:GenericFields dataType="OBJECT" name="c">
        <ns2:DataValue>
            <ns2:ObjectValue xsi:type="ns2:GenericObject">
                <ns2:ObjectType>
                    <ns2:TypeName>IncidentCustomFieldsc</ns2:TypeName>
                </ns2:ObjectType>
                <ns2:GenericFields dataType="STRING" name="custom field name ">
                    <ns2:DataValue>
                        <ns2:StringValue>Setting Custom Field!</ns2:StringValue>
                    </ns2:DataValue>
                </ns2:GenericFields>
            </ns2:ObjectValue>
        </ns2:DataValue>
    </ns2:GenericFields>
    </ns4:CustomFields>
    

    Name of custom field is custom field name (three separete words - maybe this is the reason for the error???)

    id is 117

    Error:
    

    RightNowSyncService|urn:wsdl.ws.rightnow.com/v1_2 failed Found out-of-order or unrecognized node CustomFields|urn:objects.ws.rightnow.com/v1_2 while parsing node of type Incident|urn:objects.ws.rightnow.com/v1_2 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_2::CreateMsg NULL returned from the Create deserializer due to missing or invalid XML

    Could you help me please?

    Comment

    • Barrilito van Dijk

      Hi,

      Yes the custom field name should have no spaces. You can look for the name of the custom field in the OSC console, under configurations > database > custom fields, look in the incidents fields.

      Regards

    • s k

      I will
      thanks a lot

    • Narendra Muttineni

      I think here you added the Name of the custom field, but you must add the column name of the custom field. In our custom field there are two fields one is Name of the custom field(It can have spaces) and second is column name (it should not have spaces). So please add Column name of custom field there and your issue will be resolved.

      Regards,

      Narendra

    • s k

      Thanks for help
      Checking

    • Pramod Vasudeva Murthy

      Hi S K,

      Sharing a sample code of setting a Custom field Menu value(Using ID and Menu Name) for an Incident.

      Custom field Name: Test_Menu

      Custom field data type: Menu

      Values of Menu: Item_1, Item_2, Item_3

      - VIP

    • Barrilito van Dijk

      Hi,

      Of course you should use the columnname (thank you Narendra for clearing that), that was what I meant with the name.

      Is your problem being solved?

      Regards.

    • s k

      Hi Guys!
      Thank you so much for help
      I don't have access to Oracle console
      so I'm waiting answer from my partners
      Thanks again

    • Dietrik

      You can retreive the names using the api

    • s k

      Hey Guys!
      I was informed column name
      and I used it in xml

      <ns4:CustomFields xmlns:ns2="urn:generic.ws.rightnow.com/v1_2" xsi:type="ns2:GenericObject">
          <ns2:ObjectType>
              <ns2:TypeName>IncidentCustomFields</ns2:TypeName>
          </ns2:ObjectType>
          <ns2:GenericFields dataType="OBJECT" name="c">
              <ns2:DataValue>
                  <ns2:ObjectValue xsi:type="ns2:GenericObject">
                      <ns2:ObjectType>
                          <ns2:Namespace>IncidentCustomFieldsc</ns2:Namespace>
                          <ns2:TypeName>IncidentCustomFieldsc</ns2:TypeName>
                      </ns2:ObjectType>
                      <ns2:GenericFields dataType="STRING" name="custom_field_name">
                          <ns2:DataValue>
                              <ns2:StringValue>Setting Custom Field!</ns2:StringValue>
                          </ns2:DataValue>
                      </ns2:GenericFields>
                  </ns2:ObjectValue>
              </ns2:DataValue>
          </ns2:GenericFields>
      </ns4:CustomFields>
      

      BUT I've still got the same error:
      RightNowSyncService|urn:wsdl.ws.rightnow.com/v1_2 failed Found out-of-order or unrecognized node CustomFields|urn:objects.ws.rightnow.com/v1_2 while parsing node of type Incident|urn:objects.ws.rightnow.com/v1_2 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_2::CreateMsg NULL returned from the Create deserializer due to missing or invalid XML

      Could you help me please?

    • Pramod Vasudeva Murthy

      Hi S K,

      Hope you have seen my code sample in previous post. I have shared a sample demo in it. All you need to do is change the column name of it.

      Can you please specify following info for me instead?

      Custom field name:

      Data Type:

      Data Value:<value_you_are_Setting>

      - VIP

    • s k

      Hello VIP,

      Custom field name: custom field name

      Column name: custom_field_name

      Data Type: string

      Data Value: page url (eg https://www.google.com)

      I attached my xml file

    • Pramod Vasudeva Murthy

      Attaching Input XML file:

      Custom field label: Sample Text Field

      Custom field name: sample_text_field

      Value set: https://www.google.com

      - VIP

    • Pramod Vasudeva Murthy

      PFA screen shot of record created.

    • s k

      thanks a lot
      checking

    • s k

      I'm confused..
      because I continue to get error

      if I remove part

      <ns4:CustomFields xmlns:ns2="urn:generic.ws.rightnow.com/v1_2" xsi:type="ns2:GenericObject">.......
      
         .......
      

      </ns4:CustomFields>
      incidents are created
      Maybe I'm using wrong column name
      I'll ask my partner to check it

      VIP, thanks for help again