Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Peter Keegan
    SOAP API Contacts - convert code from Custom Field to Obj...
    Topic posted October 8, 2019 by Peter KeeganGreen Ribbon: 100+ Points, last edited October 9, 2019, tagged SOAP 
    30 Views, 2 Comments
    Title:
    SOAP API Contacts - convert code from Custom Field to Obj Designer Package fields
    Summary:
    how do we convert our C# code to update Contact package fields instead of Custom Fields
    Content:

    We've been updated Contact custom fields successfully for years, however in OSvC we are converting these CFs to fields in the Object Designer in a Contacts package "CO".

    What is the simplest way to convert our C# code to update Contact package fields instead of custom fields?

    (the package fields will have the same name). Code snippet is the skeleton of the c# that is currently used to update on CF "dept".

    On attached PNG, there is the new "Dept" field in Object Designer package.

    ***UPDATED: I attached a document of new code that is attempting to add an object as a child field to Contact package "CO".

    using the sample code from http://documentation.custhelp.com/euf/assets/devdocs/cloud19c/Connect_Web_Services_for_SOAP/Default.htm

    I am getting an null reference error when I run a CREATE with the new object:  StackTrace: " at <>x.<>m0(RightNowClient <>4__this)"

    In sample code, what are Namespace and Typename?

    Do these correspond to the OSvC package name?

                    objType.Namespace = "CO";
                    objType.TypeName = "RMA";

    Version:
    WSDL 1.3
    Image:
    Code Snippet:

    Comment

     

    • Peter Keegan

      How should these be set given a custom object under Contact (see screen shot)?

                      objType.Namespace = "***";
                      objType.TypeName = "***";

    • Peter Keegan

      Nevermind! :)

      We realized that we can treat the fields in packages exactly like the Custom Fields. We just added a 2nd array element with the new fields names.

       

       

                      /* BEGIN CO */
                      GenericObject customFieldsCO = new GenericObject
                      {
                          GenericFields = new GenericField[1]
                      };
                      customFieldsCO.GenericFields[0] = _customField4;

                      customFieldsCO.ObjectType = new RNObjectType
                      {
                          TypeName = "ContactCustomFieldsc"
                      };

                      GenericField COField = new GenericField
                      {
                          name = "CO",
                          dataType = DataTypeEnum.OBJECT,
                          dataTypeSpecified = true,
                          DataValue = new DataValue
                          {
                              Items = new object[1]
                          }
                      };

                      COField.DataValue.Items[0] = customFieldsCO;
                      COField.DataValue.ItemsElementName = new ItemsChoiceType[1];
                      COField.DataValue.ItemsElementName[0] = ItemsChoiceType.ObjectValue;
      /*END CO*/

                      _rnContact.Name = _newName;
                      _rnContact.Emails = _emailArray;
                      _rnContact.Phones = _phoneArray;

                      //new custom field handling in WSDL v1.3
                      //Adding 2nd element to array for CO custom fields 20191014
                      _rnContact.CustomFields = new GenericObject
                      {
                          GenericFields = new GenericField[2]
                      };
                      _rnContact.CustomFields.GenericFields[0] = cField;
                      _rnContact.CustomFields.GenericFields[1] = COField;
                      _rnContact.CustomFields.ObjectType = new RNObjectType
                      {
                          TypeName = "ContactCustomFields"
                      };