Monday, November 26, 2018

Sample C# Code to add a Solution record and associate it to topics

 

Sample C# Code to add a Solution record and associate it to topics

Below is a sample C# code that adds a new Solution record to NetSuite. The created solution is added with Approved status and is also associated to topics

created in NetSuite under Lists> Support> Topics.


                //Create Solution and set fields
                Solution soln = new Solution();
                soln.externalId = "sln-001-script";
                soln.title = "Add Solution using C#";
                soln.displayOnline = true;
                soln.displayOnlineSpecified = true;
                soln.solutionCode = "kb-SS5.2-001";
                soln.message = "This demonstrate how to add a Solution record using C#";
                soln.longDescription = "In this sample, we will use web service ...This demonstrate how to add a Solution record using C#";
                soln.status = SolutionStatus._approved;
                soln.statusSpecified = true;
                     
                
                //Create reference to Topic of ID 6-Integration
                RecordRef topicRef1 = new RecordRef();
                topicRef1.internalId = "6";
                topicRef1.name = "Integration";
                topicRef1.type = RecordType.topic;
                topicRef1.typeSpecified = true;

                //create reference to Topic of ID 7-Web Service
                RecordRef topicRef2 = new RecordRef();
                topicRef2.internalId = "7";
                topicRef2.name = "Web Service";
                topicRef2.type = RecordType.topic;
                topicRef2.typeSpecified = true;

                //create topicList
                soln.topicsList = new SolutionTopicsList();
                soln.topicsList.topics = new SolutionTopics[2];

                //Populate topicList
                SolutionTopics topic1 = new SolutionTopics();
                topic1.topic = topicRef1;
                soln.topicsList.topics[0] = topic1;
               
                //Populate topicList
                SolutionTopics topic2 = new SolutionTopics();
                topic2.topic = topicRef2;
                soln.topicsList.topics[1] = topic2;

                //Add Solution
                WriteResponse writeRes = _service.add(soln);
                if (writeRes.status.isSuccess)
                {
                    lblResp.Text = "success";
                }
                else
                {
                    lblResp.Text = "failed";
                }

Below is the generated SOAP request:

 <soap:Body>
 <add xmlns="urn:messages_2010_2.platform.webservices.netsuite.com">
 <record externalId="sln-001-script" xsi:type="q1:Solution" xmlns:q1="urn:support_2010_2.lists.webservices.netsuite.com">
  <q1:solutionCode>kb-SS5.2-001</q1:solutionCode>
  <q1:title>Add Solution using C#</q1:title>
  <q1:message>This demonstrate how to add a Solution record using C#</q1:message>
  <q1:status>_approved</q1:status>
  <q1:displayOnline>true</q1:displayOnline>
  <q1:longDescription>In this sample, we will use web service ...This demonstrate how to add a Solution record using C#</q1:longDescription>
 <q1:topicsList>
       <q1:topics>
           <q1:topic type="topic" internalId="6">
               <name xmlns="urn:core_2010_2.platform.webservices.netsuite.com">Integration</name>
           </q1:topic>
       </q1:topics>
       <q1:topics>
           <q1:topic type="topic" internalId="7">
               <name xmlns="urn:core_2010_2.platform.webservices.netsuite.com">Web Service</name>
           </q1:topic>
       </q1:topics>
  </q1:topicsList>
  </record>
  </add>
  </soap:Body>

No comments:

Post a Comment