Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    David Wright
    Example code for updating Incident Standard Custom Objects...Answered
    Topic posted March 8, 2019 by David WrightBlue Ribbon: 750+ Points, last edited March 8, 2019, tagged SOAP 
    110 Views, 4 Comments
    Title:
    Example code for updating Incident Standard Custom Objects field?
    Content:

    Hello - would anyone be willing to share an example (ideally in .net/C#) of how to create/update a field on an Incident record that is part of the Standard Custom Object (Incident) i.e. not a custom field - using the SOAP API (CWSS)

    I have been searching the CWSS documentation but have not found what I am looking for.

    Grateful for any advice you can give.

    Thanks,

    David

     

    Best Comment

    Robert Surujbhan

    Hi David - yep, that would be a System Attribute!  That means it is the field "Need" in the object package "Standard", which is part of the Incident object.

    For now let's assume Need is a Text field?  To update it using .NET/C# and CWSS, below is some code you can review.  I have tested this using both v1.4 and v1.3 of the CCOM.  If Need is not a Text field, you can modify the DataTypeEnum (to a NAMED_ID, etc.) and ItemsChoiceType enumerations accordingly to fit the data type!

    Hope this helps?

     

    GenericField sysAttributeValue = new GenericField();
    sysAttributeValue.name = "Need";
    sysAttributeValue.dataType = DataTypeEnum.STRING;
    sysAttributeValue.dataTypeSpecified = true;
    sysAttributeValue.DataValue = new DataValue();
    sysAttributeValue.DataValue.Items = new object[1];
    sysAttributeValue.DataValue.ItemsElementName = new ItemsChoiceType[1];
    sysAttributeValue.DataValue.Items[0] = "hello David!";
    sysAttributeValue.DataValue.ItemsElementName[0] = ItemsChoiceType.StringValue;
    
    GenericObject sysAttributeField = new GenericObject();
    sysAttributeField.GenericFields = new GenericField[1];
    sysAttributeField.GenericFields[0] = sysAttributeValue;
    
    GenericField sysAttributeObject = new GenericField();
    sysAttributeObject.name = "Standard";
    sysAttributeObject.dataType = DataTypeEnum.OBJECT;
    sysAttributeObject.dataTypeSpecified = true;
    sysAttributeObject.DataValue = new DataValue();
    sysAttributeObject.DataValue.Items = new object[1];
    sysAttributeObject.DataValue.Items[0] = sysAttributeField;
    sysAttributeObject.DataValue.ItemsElementName = new ItemsChoiceType[1];
    sysAttributeObject.DataValue.ItemsElementName[0] = ItemsChoiceType.ObjectValue;
    
    theIncident.CustomFields = new GenericObject();
    theIncident.CustomFields.GenericFields = new GenericField[1];
    theIncident.CustomFields.GenericFields[0] = sysAttributeObject;
    
    RNObject[] objects2update = new RNObject[] { theIncident };
    
    //now call the SOAP API's Update operation using the RNObject array...
    

    Comment

     

    • Robert Surujbhan

      Hello David. In the CWSS documentation, look under Connect Web Services > API Operations > Update > Sample Code, and you'll see a .NET/C# example for updating standard fields on the standard Organization and Opportunity objects.  Doing this for Incident would be similar.  Does this help?

      Not sure what you meant by "Standard Custom Object (Incident)" - Incident is a Standard Object, not a Custom Object.  Can you clarify?  What field are you trying to update? Is is a System Attribute?

      • David Wright

        Hello Robert - thanks so much for your help. Sounds like I am mixing my terminology a bit, so apologies for that.

        The field we are trying to update is:

        Standard$Incident.Need

        In the PHP API this would be referred to as $incident->CustomFields->Standard->Need

        Would this be known as a System Attribute?

        Thanks,

        David

        • Robert Surujbhan

          Hi David - yep, that would be a System Attribute!  That means it is the field "Need" in the object package "Standard", which is part of the Incident object.

          For now let's assume Need is a Text field?  To update it using .NET/C# and CWSS, below is some code you can review.  I have tested this using both v1.4 and v1.3 of the CCOM.  If Need is not a Text field, you can modify the DataTypeEnum (to a NAMED_ID, etc.) and ItemsChoiceType enumerations accordingly to fit the data type!

          Hope this helps?

           

          GenericField sysAttributeValue = new GenericField();
          sysAttributeValue.name = "Need";
          sysAttributeValue.dataType = DataTypeEnum.STRING;
          sysAttributeValue.dataTypeSpecified = true;
          sysAttributeValue.DataValue = new DataValue();
          sysAttributeValue.DataValue.Items = new object[1];
          sysAttributeValue.DataValue.ItemsElementName = new ItemsChoiceType[1];
          sysAttributeValue.DataValue.Items[0] = "hello David!";
          sysAttributeValue.DataValue.ItemsElementName[0] = ItemsChoiceType.StringValue;
          
          GenericObject sysAttributeField = new GenericObject();
          sysAttributeField.GenericFields = new GenericField[1];
          sysAttributeField.GenericFields[0] = sysAttributeValue;
          
          GenericField sysAttributeObject = new GenericField();
          sysAttributeObject.name = "Standard";
          sysAttributeObject.dataType = DataTypeEnum.OBJECT;
          sysAttributeObject.dataTypeSpecified = true;
          sysAttributeObject.DataValue = new DataValue();
          sysAttributeObject.DataValue.Items = new object[1];
          sysAttributeObject.DataValue.Items[0] = sysAttributeField;
          sysAttributeObject.DataValue.ItemsElementName = new ItemsChoiceType[1];
          sysAttributeObject.DataValue.ItemsElementName[0] = ItemsChoiceType.ObjectValue;
          
          theIncident.CustomFields = new GenericObject();
          theIncident.CustomFields.GenericFields = new GenericField[1];
          theIncident.CustomFields.GenericFields[0] = sysAttributeObject;
          
          RNObject[] objects2update = new RNObject[] { theIncident };
          
          //now call the SOAP API's Update operation using the RNObject array...
          
          • David Wright

            Hello again Robert - thanks so much for your assistance, I am most grateful to you. This scenario was exactly what I was looking forward. We will now try to implement it.

            Kind regards,

            David