Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Rick Kastruba
    SOAP API Field Mapping (Update, Create) to RightNow...
    Topic posted June 12, 2012 by Rick Kastruba 
    3483 Views, 15 Comments
    Title:
    SOAP API Field Mapping (Update, Create) to RightNow Incident Fields?
    Content:

    Hi All,

    Has anybody worked with the SOAP API to develop SOAP code that updates specific fields within a RightNOW Incident? We are currently doing these updates via XML but due to requirements from RightNow are being asked to upgrade our outbound communications to the new SOAP API model.

    The problem I'm having is understanding which of the fields within the SOAP API methods (Update and Create) map to specific areas within a RightNow Incident. For example which field within the provided SOAP Update API would be used to change the RightNow Incident Status field? Entering a newly created TTTS ticket # into the TTTS Ticket Number field within the TTTS tab of the RightNow Incident is yet another example. The total list of mappings we need to know this information for is around 8.

    Basically would like to know if there is a conversion chart that answers this type of question?

    Thanks,
    Rick       

    Comment

     

    • Allan Schrum

      The documentation provides some hints as to the mapping of fields, but it is not specifically designed to answer those old-to-new mapping questions (an obvious area of improvement). I have asked that this area be improved.

      The field you are referring to is now known as "StatusWithType". It is a pair of NamedID objects (where you can use the ID or the Name as the foreign key reference or identifying key). The "Status" field is the one you wish to set. The associated "StatusType" field is read-only and is implicitly set when you set the Status field.

      I do not recognize the TTTS ticket # field. Is this a custom field? Or is the the Incident.ReferenceNumber field? The Incident.ReferenceNumber looks like '120612-001122'.

      Feel free to post your other fields and I will try to assist you. Using the pair names and descriptions that you currently use with the XML-API might be easiest.

      Could you also let us know the release of RightNow CX you are using as well as the version number of Connect? That will help us more specifically answer your questions.

      Regards,

      -Allan

    • Anil Pallichadayath

       I work with Rick kasturba and the TTTS ticket Number field refered to is a custom field   under INCIDENT -> TTTS .  We have developed the Custom Code . The code executes successfully but we do not find that the data is populated in the TTTS Ticket number field. I am pasting the code (userid & password replaced) . can someone let us know whats wrong with this code. Are we trying to populate the correct field?

      On executing the program, the console displays "Custom field value set

      import java.io.IOException;
      import java.rmi.RemoteException;

      import org.apache.axiom.om.OMElement;
      import org.apache.axiom.om.OMFactory;
      import org.apache.axiom.om.impl.OMNamespaceImpl;
      import org.apache.axiom.om.impl.llom.OMElementImpl;
      import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
      import org.apache.axis2.AxisFault;
      import org.apache.axis2.client.ServiceClient;
      import org.apache.ws.security.WSConstants;

      import com.rightnow.ws.base.ID;
      import com.rightnow.ws.base.RNObject;
      import com.rightnow.ws.generic.DataTypeEnum;
      import com.rightnow.ws.generic.DataValue;
      import com.rightnow.ws.generic.GenericField;
      import com.rightnow.ws.messages.ClientInfoHeader;
      import com.rightnow.ws.messages.UpdateProcessingOptions;
      import com.rightnow.ws.objects.Contact;
      import com.rightnow.ws.objects.Incident;
      import com.rightnow.ws.wsdl.RequestErrorFault;
      import com.rightnow.ws.wsdl.RightNowSyncService;
      import com.rightnow.ws.wsdl.RightNowSyncServiceStub;
      import com.rightnow.ws.wsdl.ServerErrorFault;
      import com.rightnow.ws.wsdl.UnexpectedErrorFault;

      ////////////////////////////////////////////////////////////////////////////////
      //RightNow Connect Sample Code
      //
      //RightNow Confidential
      //
      //Copyright 2006 - 2010 RightNow Technologies.  All Rights Reserved.
      //
      //Sample code for training only. This sample code is provided "as is" with no warranties
      //of any kind express or implied. Use of this sample code is pursuant to the applicable
      //non-disclosure agreement and or end user agreement and or partner agreement between
      //you and RightNow Technologies. You acknowledge RightNow Technologies is the exclusive
      //owner of the object code, source code, results, findings, ideas and any works developed
      //in using this sample code.
      //
      //File: SetCustomFieldValue.java
      //
      //Comments: Basic sample that demonstrates setting a custom field value.
      //
      //Notes:
      //1. You may need to adjust the username and password used in this sample.
      //
      //
      //Pre-Conditions:
      //1. You must have II_Connect_Enabled for your RightNow CX May 10 or newer site
      //2. You must have a staff account whose profile has the Public SOAP bit enabled
      //
      ////////////////////////////////////////////////////////////////////////////////
      public class SetCustomFieldValue
      {
       private RightNowSyncService _service;
       private ServiceClient _serviceClient;
       
       public SetCustomFieldValue() throws AxisFault
       {
        _service = new RightNowSyncServiceStub();
        _serviceClient = ((org.apache.axis2.client.Stub)_service)._getServiceClient();
        
        _serviceClient.addHeader(createSecurityHeader("comland", "Connect1"));
        
       }
       
       private void setCustomFieldValue() throws RemoteException, ServerErrorFault, RequestErrorFault, UnexpectedErrorFault
       {
        Contact contact = new Contact();
        ID contactID = new ID();
        contactID.setId(390266);
        contact.setID(contactID);
       
        Incident incident = new Incident();
        ID incidentID = new ID();
        incidentID.setId(1141828);
        incident.setID(incidentID);

        
        //Clear out the custom field by setting it to null.
        //This sample assumes a custom field named con_txt with data type of string.
        
        GenericField customField = new GenericField();
        customField.setName("cf_ttts_no");
        customField.setDataType(DataTypeEnum.STRING);
        customField.setDataValue(createStringDataValue("008012345"));
        
        GenericField[] customFieldArray = new GenericField[] { customField };
       
        contact.setCustomFields(customFieldArray);
       
        
        ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
        clientInfoHeader.setAppID("Set Custom Field Value");
        
        RNObject[] contactObjects = new RNObject[] { incident };
        UpdateProcessingOptions udpateProcessingOptions = new UpdateProcessingOptions();
        _service.update(contactObjects, udpateProcessingOptions, clientInfoHeader);
        
        System.out.println("Custom field value set.");
       }
       
       private DataValue createStringDataValue(String val)
       {
        DataValue dv = new DataValue();
        dv.setStringValue(val);
        return dv;
       }
       
       public static void main(String[] args)
       {
        SetCustomFieldValue setCustomFieldValue;
        try
        {
         setCustomFieldValue = new SetCustomFieldValue();
         setCustomFieldValue.setCustomFieldValue();
        }
        catch (AxisFault ex)
        {
         System.out.println("Unexpected AxisFault. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (IOException ex)
        {
         System.out.println("Unexpected IOException. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (ServerErrorFault ex)
        {
         String error = ex.getFaultMessage().getServerErrorFault().getExceptionMessage();
         System.out.println("Unexpected ServerErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (RequestErrorFault ex)
        {
         String error = ex.getFaultMessage().getRequestErrorFault().getExceptionMessage();
         System.out.println("Unexpected RequestErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (UnexpectedErrorFault ex)
        {
         String error = ex.getFaultMessage().getUnexpectedErrorFault().getExceptionMessage();
         System.out.println("Unexpected UnexpectedErrorFault. Error: " + error);
         System.exit(1);
        }
       }
       
       private OMElement createSecurityHeader(String username, String password)
       {
        OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
        OMFactory factory = new SOAP11Factory();
        OMElementImpl securityHeader;
        OMElementImpl usernameTokenElement;
        OMElementImpl usernameElement;
        OMElementImpl passwordElement;
        
        // create the Security header block
        securityHeader = new OMElementImpl("Security", wsseNS, factory);
        securityHeader.addAttribute("mustUnderstand", "1", null);
        
        // nest the UsernameToken in the Security header
        usernameTokenElement = new OMElementImpl(WSConstants.USERNAME_TOKEN_LN, wsseNS, securityHeader, factory);
        
        // nest the Username and Password elements
        usernameElement = new OMElementImpl(WSConstants.USERNAME_LN, wsseNS, usernameTokenElement, factory);
        usernameElement.setText(username);
        
        passwordElement = new OMElementImpl(WSConstants.PASSWORD_LN, wsseNS, usernameTokenElement, factory);
        passwordElement.setText(password);
        passwordElement.addAttribute(WSConstants.PASSWORD_TYPE_ATTR,
        WSConstants.PASSWORD_TEXT, null);
        
        return securityHeader;
       }
      }

    • Allan Schrum

      Hi Anil,

      Couly you please let us know which release of RightNow CX you are using and which version of Connect you are using? The version number of Connect is associated with the namespace in the WSDL to which you bound your application. In the Feb 2012 release of RightNow CX we introduced version 1.2 of Connect which changed the structure of CustomAttributes and CustomFields and unified them. CustomFields is now a GenericObject. If you search around in the RightNow Connect forum you will find discussions on this point. If you are using that version in your release, then the problem you are having has to do with the change in the structure of CustomFields. You have two approaches to solving this issue:

      1. Change your code to use the new structure. As mentioned, CustomFields is now a GenericObject rather than an array of GenericFields.
      2. Use version 1.1 instead of version 1.2 as the version 1.1 has the structure that matches the sample code you are using. Version 1.1 is deprecated in favor of version 1.2, but it is still supported for at least the next two years. While using version 1.1 is not the preferred solution, it is one that will work.

      Regards,

      -Allan

    • Anil Pallichadayath

       Hi Alan,

      I am using February 2012 Release of RightNow CX. I have developed new code using GenericObjects. I am pasting the code and the error I get. I have also attached two screetshot to show what exactly I am trying to achieve.   Looking at the attached screenshots you will see that I am trying to populate the TTTS Ticket Number. Since the TTTS Ticket Number is a customfield under Incident,  I am not sure how I would pass the Incident ID in my program.


      import java.io.IOException;
      import java.rmi.RemoteException;

      import org.apache.axiom.om.OMElement;
      import org.apache.axiom.om.OMFactory;
      import org.apache.axiom.om.impl.OMNamespaceImpl;
      import org.apache.axiom.om.impl.llom.OMElementImpl;
      import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
      import org.apache.axis2.AxisFault;
      import org.apache.axis2.client.ServiceClient;
      import org.apache.ws.security.WSConstants;

      import com.rightnow.ws.base.ID;
      import com.rightnow.ws.base.RNObject;
      import com.rightnow.ws.generic.RNObjectType;
      import com.rightnow.ws.generic.DataTypeEnum;
      import com.rightnow.ws.generic.DataValue;
      import com.rightnow.ws.generic.GenericField;
      import com.rightnow.ws.generic.GenericObject;
      import com.rightnow.ws.messages.ClientInfoHeader;
      import com.rightnow.ws.messages.UpdateProcessingOptions;
      import com.rightnow.ws.objects.Contact;
      import com.rightnow.ws.objects.Incident;
      import com.rightnow.ws.wsdl.RequestErrorFault;
      import com.rightnow.ws.wsdl.RightNowSyncService;
      import com.rightnow.ws.wsdl.RightNowSyncServiceStub;
      import com.rightnow.ws.wsdl.ServerErrorFault;
      import com.rightnow.ws.wsdl.UnexpectedErrorFault;

      ////////////////////////////////////////////////////////////////////////////////

      public class TicketNo
      {
       private RightNowSyncService _service;
       private ServiceClient _serviceClient;
       
       public TicketNo() throws AxisFault
       {
        _service = new RightNowSyncServiceStub();
        _serviceClient = ((org.apache.axis2.client.Stub)_service)._getServiceClient();
        
        _serviceClient.addHeader(createSecurityHeader("comland", "Connect1"));
        
       }
       
       public void setCustomFieldValue() throws RemoteException, ServerErrorFault, RequestErrorFault, UnexpectedErrorFault
       {
        
        //Clear out the custom field by setting it to null.
        //This sample assumes a custom field named cf_ttts_no with data type of string.
        
        GenericField ttts_tkt = new GenericField();
        ttts_tkt.setName("cf_ttts_no");
        ttts_tkt.setDataType(DataTypeEnum.STRING);
        DataValue dv = new DataValue();
        dv.setStringValue("008016862");
        ttts_tkt.setDataValue(dv);
        
        GenericObject tkt_package = new GenericObject();
        tkt_package.setGenericFields( new GenericField[] { ttts_tkt } );
        GenericField tkt_package_gf = new GenericField();
        tkt_package_gf.setName("TTTS");
        tkt_package_gf.setDataType(DataTypeEnum.OBJECT);
        
        DataValue dvObject = new DataValue();
        dvObject.setObjectValue(tkt_package);
        tkt_package_gf.setDataValue(dvObject);
        
        GenericObject cWrapper = new GenericObject();
        RNObjectType cWrapperType = new RNObjectType();
        cWrapperType.setTypeName("Incident");
        cWrapper.setObjectType(cWrapperType);
        cWrapper.setGenericFields(new GenericField[] { tkt_package_gf });
        
        Incident incident = new Incident();
        incident.setCustomFields(cWrapper);
       // incident.setLookupName("1141812");
        
        
        ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
        clientInfoHeader.setAppID("Set Custom Field Value");
        
        RNObject[] contactObjects = new RNObject[] { incident };
        UpdateProcessingOptions udpateProcessingOptions = new UpdateProcessingOptions();
        _service.update(contactObjects, udpateProcessingOptions, clientInfoHeader);
        
        System.out.println("Custom field value set.");
       }
       
       public static void main(String[] args)
       {
        TicketNo ticketNo;
        try
        {
         ticketNo = new TicketNo();
         ticketNo.setCustomFieldValue();
        }
        catch (AxisFault ex)
        {
         System.out.println("Unexpected AxisFault. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (IOException ex)
        {
         System.out.println("Unexpected IOException. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (ServerErrorFault ex)
        {
         String error = ex.getFaultMessage().getServerErrorFault().getExceptionMessage();
         System.out.println("Unexpected ServerErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (RequestErrorFault ex)
        {
         String error = ex.getFaultMessage().getRequestErrorFault().getExceptionMessage();
         System.out.println("Unexpected RequestErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (UnexpectedErrorFault ex)
        {
         String error = ex.getFaultMessage().getUnexpectedErrorFault().getExceptionMessage();
         System.out.println("Unexpected UnexpectedErrorFault. Error: " + error);
         System.exit(1);
        }
       }
       
       private OMElement createSecurityHeader(String username, String password)
       {
        OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
        OMFactory factory = new SOAP11Factory();
        OMElementImpl securityHeader;
        OMElementImpl usernameTokenElement;
        OMElementImpl usernameElement;
        OMElementImpl passwordElement;
        
        // create the Security header block
        securityHeader = new OMElementImpl("Security", wsseNS, factory);
        securityHeader.addAttribute("mustUnderstand", "1", null);
        
        // nest the UsernameToken in the Security header
        usernameTokenElement = new OMElementImpl(WSConstants.USERNAME_TOKEN_LN, wsseNS, securityHeader, factory);
        
        // nest the Username and Password elements
        usernameElement = new OMElementImpl(WSConstants.USERNAME_LN, wsseNS, usernameTokenElement, factory);
        usernameElement.setText(username);
        
        passwordElement = new OMElementImpl(WSConstants.PASSWORD_LN, wsseNS, usernameTokenElement, factory);
        passwordElement.setText(password);
        passwordElement.addAttribute(WSConstants.PASSWORD_TYPE_ATTR,
        WSConstants.PASSWORD_TEXT, null);
        
        return securityHeader;
       }
      }

       Console Error :

      log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisOperation).

      log4j:WARN Please initialize the log4j system properly.

      Unexpected RequestErrorFault. Error: Invalid ID: No Incident record found with LookupName = ''

       

    • Allan Schrum

      H Anil,

      First, when dealing with GenericFields do not bother setting the DataType as that is only used for out-going requests. It is ignored on input. If the custom field is a string (and we can tell from the internal metadata) then we will look for its value in the StringValue field. If it is not there, then we will throw an error (No value found in StringValue, or something similar).

      ttts_tkt is correct.

      tkt_package_gf is close (wrapping ttts_tkt using a GenericObject). Since this is a custom field (using the custom field editor) rather than a custom attribute (using the Object Designer editor), set the package name to "c" (lower case "C"): setName("c");

      cWrapper is close. Leave off the RNObjectType (it is not needed here in this context). RNObjectType is necessary when dealing with a top-level object (such as an Incident). Here, this is a sub-object (CustomFields) so it is not necessary.

      Setup of your Incident object is fine in that the CustomFields is correctly set. Now we need to identify which Incident you are referencing. You have two approaches depending upon what information you know. Since this is a Feb 2012 site using version 1.2, you can use the LookupName (as you have commented out) to lookup the Incident. The LookupName field for Incident is ReferenceNumber. Thus if you know the reference number (e.g. something that looks like '120619-001123') then you can set that field. Otherwise, if you know the ID (and this is the typical preferred way) then set the ID of the Incident (e.g. incident.setID( myID ) ). The "id" attribute of the myID object you'll need to create should be set to the numeric value of the ID of the Incident.

      The rest looks fine. Of course, my visual compiler might have a syntax error or two, so I leave it to you to correct my mistakes. Please let us know how this progresses.

      Regards,

      -Allan

       

    • Anil Pallichadayath

       Hi  Allan ,

      I made the changes you suggested. Now my code works fine and I get a successful return message station ""Custom field value set."   However I do not find the TTTS Ticket number set/displayed on the Incident system. Now  I am wondering if the system is updating a different field or possibly the updates are not being commited into the incident system database. The only other issue I can think of is that the the field name  "cf_ttts_no"    (   ttts_tkt.setName("cf_ttts_no") )  is not correct. I even did a debug to ensure that I am sending the correct values.  Now I believe someone should look at the RightNow Incident system  to troubleshoot the cause.  I am pasting my updated code (userid & password masked). Would appreciate your help on getting this resolved.

      import java.io.IOException;
      import java.rmi.RemoteException;

      import org.apache.axiom.om.OMElement;
      import org.apache.axiom.om.OMFactory;
      import org.apache.axiom.om.impl.OMNamespaceImpl;
      import org.apache.axiom.om.impl.llom.OMElementImpl;
      import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
      import org.apache.axis2.AxisFault;
      import org.apache.axis2.client.ServiceClient;
      import org.apache.ws.security.WSConstants;

      import com.rightnow.ws.base.ID;
      import com.rightnow.ws.base.RNObject;
      import com.rightnow.ws.generic.RNObjectType;
      import com.rightnow.ws.generic.DataTypeEnum;
      import com.rightnow.ws.generic.DataValue;
      import com.rightnow.ws.generic.GenericField;
      import com.rightnow.ws.generic.GenericObject;
      import com.rightnow.ws.messages.ClientInfoHeader;
      import com.rightnow.ws.messages.CreateProcessingOptions;
      import com.rightnow.ws.messages.RNObjectsResult;
      import com.rightnow.ws.messages.UpdateProcessingOptions;
      import com.rightnow.ws.objects.Contact;
      import com.rightnow.ws.objects.Incident;
      import com.rightnow.ws.wsdl.RequestErrorFault;
      import com.rightnow.ws.wsdl.RightNowSyncService;
      import com.rightnow.ws.wsdl.RightNowSyncServiceStub;
      import com.rightnow.ws.wsdl.ServerErrorFault;
      import com.rightnow.ws.wsdl.UnexpectedErrorFault;

      ////////////////////////////////////////////////////////////////////////////////
      //RightNow Connect Sample Code
      //
      //RightNow Confidential
      //
      //Copyright 2006 - 2010 RightNow Technologies.  All Rights Reserved.
      //
      //Sample code for training only. This sample code is provided "as is" with no warranties
      //of any kind express or implied. Use of this sample code is pursuant to the applicable
      //non-disclosure agreement and or end user agreement and or partner agreement between
      //you and RightNow Technologies. You acknowledge RightNow Technologies is the exclusive
      //owner of the object code, source code, results, findings, ideas and any works developed
      //in using this sample code.
      //
      //File: SetCustomFieldValue.java
      //
      //Comments: Basic sample that demonstrates setting a custom field value.
      //
      //Notes:
      //1. You may need to adjust the username and password used in this sample.
      //
      //
      //Pre-Conditions:
      //1. You must have II_Connect_Enabled for your RightNow CX May 10 or newer site
      //2. You must have a staff account whose profile has the Public SOAP bit enabled
      //
      ////////////////////////////////////////////////////////////////////////////////
      public class TicketNo
      {
       private RightNowSyncService _service;
       private ServiceClient _serviceClient;
       
       public TicketNo() throws AxisFault
       {
        _service = new RightNowSyncServiceStub();
        _serviceClient = ((org.apache.axis2.client.Stub)_service)._getServiceClient();
        
        _serviceClient.addHeader(createSecurityHeader("xxxxxxx", "xxxxxxx"));
        
       }
       
       public void setCustomFieldValue() throws RemoteException, ServerErrorFault, RequestErrorFault, UnexpectedErrorFault
       {
        
        //Clear out the custom field by setting it to null.
        //This sample assumes a custom field named cf_ttts_no with data type of string.
       
        
        GenericField ttts_tkt = new GenericField();
        ttts_tkt.setName("cf_ttts_no");
       // ttts_tkt.setDataType(DataTypeEnum.STRING);
        DataValue dv = new DataValue();
        dv.setStringValue("008016862");
        ttts_tkt.setDataValue(dv);
        
        GenericObject tkt_package = new GenericObject();
        tkt_package.setGenericFields( new GenericField[] { ttts_tkt } );
        GenericField tkt_package_gf = new GenericField();
        tkt_package_gf.setName("c");
        tkt_package_gf.setDataType(DataTypeEnum.OBJECT);
        
        DataValue dvObject = new DataValue();
        dvObject.setObjectValue(tkt_package);
        tkt_package_gf.setDataValue(dvObject);
        
        GenericObject cWrapper = new GenericObject();
       // RNObjectType cWrapperType = new RNObjectType();
       // cWrapperType.setTypeName("Incident");
       // cWrapper.setObjectType(cWrapperType);
        cWrapper.setGenericFields(new GenericField[] { tkt_package_gf });

        Incident incident = new Incident();
        ID incidentID = new ID();
        incidentID.setId(1141812);
        incident.setID(incidentID);
        
       // incident.setCustomFields(cWrapper);
       
       
        ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
        clientInfoHeader.setAppID("Set Custom Field Value");
       
         
        RNObject[] contactObjects = new RNObject[] { incident };
        
        UpdateProcessingOptions udpateProcessingOptions = new UpdateProcessingOptions();
        _service.update(contactObjects, udpateProcessingOptions, clientInfoHeader);
          
        System.out.println("Custom field value set." );
       }
       
       public static void main(String[] args)
       {
        TicketNo ticketNo;
        try
        {
         ticketNo = new TicketNo();
         ticketNo.setCustomFieldValue();
        }
        catch (AxisFault ex)
        {
         System.out.println("Unexpected AxisFault. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (IOException ex)
        {
         System.out.println("Unexpected IOException. Error: " + ex.getMessage());
         System.exit(1);
        }
        catch (ServerErrorFault ex)
        {
         String error = ex.getFaultMessage().getServerErrorFault().getExceptionMessage();
         System.out.println("Unexpected ServerErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (RequestErrorFault ex)
        {
         String error = ex.getFaultMessage().getRequestErrorFault().getExceptionMessage();
         System.out.println("Unexpected RequestErrorFault. Error: " + error);
         System.exit(1);
        }
        catch (UnexpectedErrorFault ex)
        {
         String error = ex.getFaultMessage().getUnexpectedErrorFault().getExceptionMessage();
         System.out.println("Unexpected UnexpectedErrorFault. Error: " + error);
         System.exit(1);
        }
       }
       
       private OMElement createSecurityHeader(String username, String password)
       {
        OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
        OMFactory factory = new SOAP11Factory();
        OMElementImpl securityHeader;
        OMElementImpl usernameTokenElement;
        OMElementImpl usernameElement;
        OMElementImpl passwordElement;
        
        // create the Security header block
        securityHeader = new OMElementImpl("Security", wsseNS, factory);
        securityHeader.addAttribute("mustUnderstand", "1", null);
        
        // nest the UsernameToken in the Security header
        usernameTokenElement = new OMElementImpl(WSConstants.USERNAME_TOKEN_LN, wsseNS, securityHeader, factory);
        
        // nest the Username and Password elements
        usernameElement = new OMElementImpl(WSConstants.USERNAME_LN, wsseNS, usernameTokenElement, factory);
        usernameElement.setText(username);
        
        passwordElement = new OMElementImpl(WSConstants.PASSWORD_LN, wsseNS, usernameTokenElement, factory);
        passwordElement.setText(password);
        passwordElement.addAttribute(WSConstants.PASSWORD_TYPE_ATTR,
        WSConstants.PASSWORD_TEXT, null);
        
        return securityHeader;
       }
      }

      Console Message :

      log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisOperation).

      log4j:WARN Please initialize the log4j system properly.

       

      Custom field value set.

       

    • Rick Kastruba

      Hi All,

      Not sure if this has anything to do with Anil's problem?

      On our test site (https://dealerconnect--tst.custhelp.com/cgi-bin/dealerconnect.cfg/php/admin/launch.php) I was able to create and new Incident (120622-000002); however, when I went back to add a private not to that same Incident received error (see attached file).

      Rick

    • Allan Schrum

      Hi Anil (and Rick),

      In the latest code posted there is a line that is commented that assigns the CustomFields for the Incident:

      // incident.setCustomFields(cWrapper);

      With that line commented the custom field information is not sent to the server. Could you try uncommenting that line and see if it works?

      As far as the field name is concerned, the "cf_ttts_no" is the correct name. The name to use is the one that corresponds to the column name. The problem with custom fields is that the labels that describe the field do not have to be unique. So using the column name is the correct name to use. You are also using package "c" which is reserved for custom fields.

      If this does not work the next step is to turn on logging on the server and capture the request and the logs and for someone to examine them. The core "UPDATE" statement that is generated is what we would need to inspect. To do that you'll need to contact Customer Care.

      But let's see if your code works or not.

      Regards,

      -Allan

    • Anil Pallichadayath

       Hi Allan,

      I had tried with all the below 3 lines of code but it would give me a compilation error. Thats when I commented out the third line.

      incidentID.setId(1141812);
      incident.setID(incidentID);

      incident.setCustomFields(cWrapper);

      I had also tried with the third line   ( incident.setCustomFields(cWrapper);   )   but would not work without a incidentID.

      Apart from these we also find that we are unable to update the ticketnumber directly on the dealerconnect test site. Thats what leads us to beleieve that it could be a problem with the test environment rather than the code itself. Anyways would appreciate if there is any ways by which we can use incident.setCustomFields(cWrapper); along with the incident id.


       


       

       

    • Allan Schrum

      You need all three lines. What is the compilation error associated with the third line?

      -Allan

    • Anil Pallichadayath

      Hi Allan,

      FInally I got it working. The Problem was with the Test site  which was not working. Jared had corrected the on Friday. Sorry, i was not getting a compilation error , probably a run time error.  Thanks for all your support.

      Anil

        

    • Allan Schrum

      Great news! You are very welcome.

      Regards,

      -Allan

    • Govindharaju Gurusamy

      Hi All,

                         I want to update mutiple contact custom field in rightnow using java  code. I have sample code for updating one custom field but i dont have code for updating multiple custom fields. If you have any sample code please share with me. Please correct my code for multiple update

       

      GenericObject genericObject2 = new GenericObject();
                  RNObjectType objType2 = new RNObjectType();
                  objType2.setTypeName("ContactCustomFieldsc");
                  GenericField[] genericFieldsArray2 = new GenericField[1];
                  GenericField genericField2 = new GenericField();
                  genericField2.setDataType(DataTypeEnum.STRING);
                  genericField2.setName("kq_fusion_id");
                  genericField2.setDataValue(createStringDataValue(conVo.fusionId));
                  genericFieldsArray2[0] = genericField2;
                  genericObject2.setGenericFields(genericFieldsArray2);
                  genericObject2.setObjectType(objType2);
                  
                  GenericObject genericObject = new GenericObject();
                  RNObjectType objType = new RNObjectType();
                  objType.setTypeName("ContactCustomFields");
                  GenericField[] genericFieldsArray = new GenericField[1];
                  GenericField genericField = new GenericField();
                  genericField.setName("c");
                  genericField.setDataType(DataTypeEnum.OBJECT);
                  genericField.setDataValue(createObjectValue(genericObject2));
                  genericFieldsArray[0] = genericField;
                  genericObject.setGenericFields(genericFieldsArray);
                  genericObject.setObjectType(objType);
                  firstContact.setCustomFields(genericObject);

       

      Thanks

      Govindh 

    • Allan Schrum

      I'm sorry that I do not have sample code, but the idea is to add another GenericField to the GenericObject that represents the "c" package. In your code the field "kq_fusion_id" is a custom field that is added to the array of GenericFields on the GenericObject. Instead of only adding one element to that array, add two, or three, or as many as you need.

      For custom attributes (also managed via "CustomFields") the same is true, just the package changes from "c" to your package associated with the custom attributes. This is seen in the Object Designer as you added them to various objects in the Agent Desktop.

      Regards,

      -Allan

    • Raksh Pal

      Hi,

      Please Reviev my code. I am trying to check duplicate incident custom fields in oracle right now using soap api using c# but no success.

       

      public long GetIncidentId(string _docId)
              {

                  try
                  {

                   //  GenericObject incidentID = GetGenericIncident1(_docId);
                      Incident incidentID = GetGenericIncident(_docId);
                      // GenericField loginGenericField = createIncidentCustomFields("c$document_id", _docId);

                      ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                     

                      clientInfoHeader.AppID =  "Data Provider";

                      var binding = new CustomBinding(new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential) { MaxReceivedMessageSize = 20000000 });
                      var securityElement = binding.Elements.OfType<TransportSecurityBindingElement>().First();
                      securityElement.IncludeTimestamp = false;

                      GetProcessingOptions options = new GetProcessingOptions();
                      options.FetchAllNames = false;               
                    
                      

                         RNObject[] contactObjects = new RNObject[] { incidentID };              


                    
                     
                      var epAddress = new EndpointAddress("soap service url");
                      _service = new RightNowSyncPortClient(binding, epAddress);
                      //  _service = new RightNowSyncPortClient(binding, epAddress);
                      _service.ClientCredentials.UserName.UserName = "test-user";
                      _service.ClientCredentials.UserName.Password = "test-passowrd";


                      RNObject[] objectResult = new RNObject[1000];
                      // objectResult = new RNObject[1000];

                      APIAccessRequestHeader objApiHeader = new APIAccessRequestHeader();
                      ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//add
                      _service.Get(clientInfoHeader, objApiHeader, contactObjects, options, out objectResult);
                      return objectResult[0].ID.id;
                  }
                  catch (Exception ex)
                  {
                      // ClsWriteLogFile.WriteLogfailed(String.Format("{0} @ {1}", "New Incident not created for DOC_ID: '" + row["DOC_ID"] + "'  Error: '" + ex.Message + "'  at ", DateTime.Now));
                      return 0;
                      //throw;
                  }
                  // return objectResult[0].ID.id;
              }

      private Incident GetGenericIncident(string _docId)
              {
                  Incident incident = new Incident();
                  try
                  {

                      incident.CustomFields = new GenericObject();//
                      incident.CustomFields.GenericFields = new GenericField[1];//

                      GenericField dateofbirth = new GenericField();
                      dateofbirth.name = "document_id";
                      dateofbirth.dataType = DataTypeEnum.STRING;
                      dateofbirth.dataTypeSpecified = true;
                      dateofbirth.DataValue = new DataValue();
                      dateofbirth.DataValue.Items = new object[1];
                      dateofbirth.DataValue.ItemsElementName = new ItemsChoiceType[1];
                   


                  dateofbirth.DataValue.Items[0] = _docId;
                  dateofbirth.DataValue.ItemsElementName[0] = ItemsChoiceType.StringValue;


                  GenericObject customFieldobjoect2 = new GenericObject();
                  customFieldobjoect2.GenericFields = new GenericField[1];


                  customFieldobjoect2.GenericFields[0] = dateofbirth;

                  customFieldobjoect2.ObjectType = new RNObjectType();
                  customFieldobjoect2.ObjectType.TypeName = "Incidents.c$document_id";

       

                  GenericField COField = new GenericField();
                  COField.name = "c";// "CO";
                  COField.dataType = DataTypeEnum.OBJECT;
                  COField.dataTypeSpecified = true;
                  COField.DataValue = new DataValue();
                  COField.DataValue.Items = new object[1];
                  COField.DataValue.Items[0] = customFieldobjoect2;
                  COField.DataValue.ItemsElementName = new ItemsChoiceType[1];
                  COField.DataValue.ItemsElementName[0] = ItemsChoiceType.ObjectValue;


                  incident.CustomFields.GenericFields[0] = COField;
                  incident.CustomFields.ObjectType = new RNObjectType();
                  incident.CustomFields.ObjectType.TypeName = "Incidents.c$document_id";
                     


                  }
                  catch (Exception ex)
                  {

                     // throw;
                  }

                  return incident;
              }