This is a public Forum  publicRSS

Topic

    SAJI MATHEW
    C# Code to create custom object on RightNow
    Topic posted February 26, 2018 by SAJI MATHEWApprentice 
    350 Views, 6 Comments
    Title:
    C# Code to create custom object on RightNow
    Content:

    I think most of the developers come across the requirement to integrate third-party application with RN system. Sometimes we might need to create entries in the Custom object. Here is the sample code to create custom object entries in RN CO.

    Code Block:

    Answer

     

    • Anuj Behl

      Good one, Saji. A real-life example is always welcomed and a better choice.

      And if anyone comes looking for more sample codes, there's a comprehensive collection of general samples from the documentation here

      -Anuj

       

    • Pramod Vasudeva Murthy

      Goo one, SAJI yes

      ~VIP

    • Edson Junior

      Nice!!  yes

    • Sergio Farias

      ///////***********************CAMPOS CUSTOMIZADOS
                      List<ServiceReference1.GenericField> dv_lista = new List<ServiceReference1.GenericField> { };
                      dv_lista.Add(createGenericField("dtp_idcontato", ServiceReference1.ItemsChoiceType.StringValue, identificacao));
                      dv_lista.Add(createGenericField("dtp_cargo", ServiceReference1.ItemsChoiceType.StringValue, cargo));
                    
                      ServiceReference1.GenericObject gen = new ServiceReference1.GenericObject();
                      gen.GenericFields = dv_lista.ToArray();

                      //create a enclosure GenericObject containing 'c'
                      List<ServiceReference1.GenericField> dv_lista_fields = new List<ServiceReference1.GenericField> { };
                      dv_lista_fields.Add(createGenericField("c", ServiceReference1.ItemsChoiceType.ObjectValue, gen ));

                      ServiceReference1.GenericObject genericObj = new ServiceReference1.GenericObject();
                      genericObj.GenericFields = dv_lista_fields.ToArray();

                      // coloca os campos genericos no objeto - sergio - 24/07/18
                      account.CustomFields = genericObj;
                      /////***********************************************************************************************************

    • Sergio Farias

      string identificacao="teste";
                      string cargo ="Analista sistema/CX";
                      ///////***********************CAMPOS CUSTOMIZADOS
                      List<ServiceReference1.GenericField> dv_lista = new List<ServiceReference1.GenericField> { };
                      dv_lista.Add(createGenericField("dtp_idcontato", ServiceReference1.ItemsChoiceType.StringValue, identificacao));
                      dv_lista.Add(createGenericField("dtp_cargo", ServiceReference1.ItemsChoiceType.StringValue, cargo));
                    
                      ServiceReference1.GenericObject gen = new ServiceReference1.GenericObject();
                      gen.GenericFields = dv_lista.ToArray();

                      //create a enclosure GenericObject containing 'c'
                      List<ServiceReference1.GenericField> dv_lista_fields = new List<ServiceReference1.GenericField> { };
                      dv_lista_fields.Add(createGenericField("c", ServiceReference1.ItemsChoiceType.ObjectValue, gen ));

                      ServiceReference1.GenericObject genericObj = new ServiceReference1.GenericObject();
                      genericObj.GenericFields = dv_lista_fields.ToArray();

                      // coloca os campos genericos no objeto - sergio - 24/07/18
                      account.CustomFields = genericObj;
                      /////***********************************************************************************************************

                 private ServiceReference1.GenericField createGenericField(string Name, ServiceReference1.ItemsChoiceType itemsChoiceType, object Value)
              {
                  ServiceReference1.GenericField orderHistoryFld = new ServiceReference1.GenericField();
                  orderHistoryFld.name = Name;
                  orderHistoryFld.DataValue = new ServiceReference1.DataValue();
                  orderHistoryFld.DataValue.ItemsElementName = new ServiceReference1.ItemsChoiceType[] { itemsChoiceType };
                  orderHistoryFld.DataValue.Items = new object[] { Value };
                  return orderHistoryFld;
              }

    • Deepu Kolkkadan

      This is really helpful, thanks Sajismiley