Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Mukesh Kalal
    Create Custom object through Soap API
    Topic posted April 27, 2019 by Mukesh KalalRed Ribbon: 250+ Points, tagged SOAP 
    103 Views, 2 Comments
    Title:
    Create Custom object through Soap API
    Summary:
    Sample soap Envelop to create custom object
    Content:

    Hello Everyone ,

    We are trying to create a custom(insert value in custom object)  through standard Soap API.

    Custom object which we are trying to create is child object of contact with the following fields .

    Name(text)

    email address (text)

    Mobile_number(text)

    Date_of_birth(Date)  

    Contact(integer [contact id])

    Please provide sample code for above request.  

    Version:
    17 D

    Comment

     

    • Suresh Thirukoti

      Hi Mukesh,

      Below is the sample code:

      GenericObject go = new GenericObject();

      //Set the object type

      RNObjectType objType = new RNObjectType();

      objType.Namespace = "Package Name";

      objType.TypeName = "Object Name";

      go.ObjectType = objType;

      List<GenericField> gfs = new List<GenericField>();
       

      gfs.Add(createGenericField("Contact", ItemsChoiceType.NamedIDValue, new NamedID { new ID { id=123, idspecified=true}} ));

       
      gfs.Add(createGenericField("Name", ItemsChoiceType.StringValue, "nAME"));

      gfs.Add(createGenericField("email_address", ItemsChoiceType.StringValue, "email@addres.com"));

      gfs.Add(createGenericField("Mobile_number", ItemsChoiceType.StringValue, "9493943943"));

      gfs.Add(createGenericField("Date_of_birth", ItemsChoiceType.DateTimeValue, datetime.now()));

      gfs.Add(createGenericField("ConversationSID", ItemsChoiceType.StringValue, conversationID));


      go.GenericFields = gfs.ToArray();

      CreateProcessingOptions options = new CreateProcessingOptions();

      options.SuppressExternalEvents = false;

      options.SuppressRules = false;


      CreateRequest createRequest = new CreateRequest(getClientInfoHeader(), new APIAccessRequestHeader { Token = "" }, new RNObject[] { go }, options);

      CreateResponse createResponcse = this.getChannel().Create(createRequest);

      RNObject[] results = createResponcse.RNObjectsResult;

      // check result and save incident id

      if (results != null && results.Length > 0)

      {

      foreach (GenericObject result in results)

      {

      if (result != null && result.ID != null)

      {

       

      }

      }

      }
       
       
       


      public GenericField createGenericField(string Name, ItemsChoiceType itemsChoiceType, object Value)

      {

      GenericField gf = new GenericField();

      gf.name = Name;

      gf.dataTypeSpecified = true;

      gf.DataValue = new DataValue();

      gf.DataValue.ItemsElementName = new ItemsChoiceType[] { itemsChoiceType };

      gf.DataValue.Items = new object[] { Value };

      return gf;

      }


      ~Suresh