Example of Setting Values for Multiple Segments

The following example shows how to set values for two custom segments on the same record instance. Specifically, this example shows how to add a customer record and set values for the segments as part of the add request. One segment is of type List/Record and the other is of type Multiple Select. This example assumes that the segment has already been created with a series of possible values. This example also assumes that the segment has already been applied to the customer record type.

C#

          private void addCustomer()
{ // If this is a OneWorld account, define a subsidiary. RecordRef mySubsidiary = new RecordRef(); mySubsidiary.internalId = "1"; // Define values for the body fields of the customer record. Customer myCustomer = new Customer(); myCustomer.externalId = "5033BA1"; myCustomer.companyName= "Acme Inc."; myCustomer.subsidiary = mySubsidiary; // Define a MultiSelectCustomFieldRef object to represent the multiple select segment field. MultiSelectCustomFieldRef multiSelectCustomFieldRef = new MultiSelectCustomFieldRef(); // Create an array of two values. Use the array to identify two of the custom segment's available values. ListOrRecordRef[] multiSelectValueArray = new ListOrRecordRef[2]; multiSelectValueArray[0] = new ListOrRecordRef(); multiSelectValueArray[0].internalId = "1"; multiSelectValueArray[1] = new ListOrRecordRef(); multiSelectValueArray[1].internalId = "4"; multiSelectCustomFieldRef.value = multiSelectValueArray; multiSelectCustomFieldRef.scriptId = "cseg_upsellareas"; // Define a SelectCustomFieldRef object to represent the list/record segment field. SelectCustomFieldRef selectCustomFieldRef = new SelectCustomFieldRef(); ListOrRecordRef custSelectValue = new ListOrRecordRef(); custSelectValue.internalId = "1"; selectCustomFieldRef.value = custSelectValue; selectCustomFieldRef.scriptId = "cseg_ranking"; // Define the record's custom field list. CustomFieldRef[] customFieldRefArray = new CustomFieldRef[2]; customFieldRefArray[0] = multiSelectCustomFieldRef; customFieldRefArray[1] = selectCustomFieldRef; myCustomer.customFieldList = customFieldRefArray; // Add the customer. _service.add(myCustomer);
} 

        

SOAP Request

          <soap:Body>
   <add xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
      <record externalId="5033BA1" xsi:type="q1:Customer" xmlns:q1="urn:relationships_2017_1.lists.webservices.netsuite.com">
         <q1:companyName>Acme Inc.</q1:companyName>
         <q1:subsidiary internalId="1"/>
         <q1:customFieldList>
            <customField scriptId="cseg_upsellareas" xsi:type="MultiSelectCustomFieldRef" xmlns="urn:core_2017_1.platform.webservices.netsuite.com">
               <value internalId="1"/>
               <value internalId="4"/>
          </customField>
            <customField scriptId="cseg_ranking" xsi:type="SelectCustomFieldRef" xmlns="urn:core_2017_1.platform.webservices.netsuite.com">
               <value internalId="1"/>
          </customField>
         </q1:customFieldList>
    </record>
   </add>
</soap:Body> 

        

SOAP Response

          <soapenv:Body>
   <addResponse xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
      <writeResponse>
         <platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2017_1.platform.webservices.netsuite.com"/>
            <baseRef xsi:type="platformCore:RecordRef" type="customer" externalId="5033BA1" internalId="4352" xmlns:platformCore="urn:core_2017_1.platform.webservices.netsuite.com"/>
      </writeResponse>
   </addResponse>
</soapenv:Body> 

        

Related Topics

Custom Segment Types
Applying a Custom Segment to Record Types
Value Creation for Custom Segments
Custom Segments
CustomFieldLists for Setting Custom Segment Values
Custom Segment Types
Identifying the Correct Script ID for a Custom Segment
Example of Setting a List/Record Segment Value

General Notices