Reputation: 23
I am trying to retrieve the values of the NetSuite Custom Segments using the SOAP api. For example, considering this custom segment in NetSuite:
I am trying to retrieve a result which has the following values:
{
"id": "1",
"value": "polo"
},
{
"id": "2",
"value": "crew neck"
},
{
"id": "3",
"value": "v neck"
},
{
"id": "4",
"value": "round"
}
I tried what is mentioned in SuiteAnswers and NetSuite SOAP guide, but I had no success. I appreciate any help.
I tried sending a Custom Record Search as it was mentioned in other questions:
<SOAP-ENV:Body>
<ns4:search>
<ns4:searchRecord xsi:type="ns3:CustomRecordSearch">
<ns3:basic>
<ns2:recType xsi:type="ns1:CustomizationRef" scriptId="customrecord_cseg1" type="customRecordType" internalId="5">
<ns1:name>type-Tshirt</ns1:name>
</ns2:recType>
</ns3:basic>
</ns4:searchRecord>
</ns4:search>
</SOAP-ENV:Body>
But this results in an error response:
<searchResponse xmlns="urn:messages_2022_2.platform.webservices.netsuite.com">
<platformCore:searchResult xmlns:platformCore="urn:core_2022_2.platform.webservices.netsuite.com">
<platformCore:status isSuccess="false">
<platformCore:statusDetail type="ERROR">
<platformCore:code>INVALID_CSTM_RCRD_TYPE_KEY</platformCore:code>
<platformCore:message>5 refers to a custom list. To get the contents of this list, use the 'get' or 'getAll' operation with a RecordRef of type 'customList'</platformCore:message>
</platformCore:statusDetail>
</platformCore:status>
</platformCore:searchResult>
</searchResponse>
I also tried sending a Get Request as was recommended in some links:
<SOAP-ENV:Body>
<ns2:get>
<ns2:baseRef xsi:type="ns1:RecordRef" type="customSegment" internalId="5"/>
</ns2:get>
</SOAP-ENV:Body>
This will return only extra information about the custom segment and no values are returned:
<soapenv:Body>
<getResponse xmlns="urn:messages_2022_2.platform.webservices.netsuite.com">
<readResponse>
<platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2022_2.platform.webservices.netsuite.com"/>
<record xsi:type="setupCustom:CustomSegment" internalId="5" xmlns:setupCustom="urn:customization_2022_2.setup.webservices.netsuite.com">
<setupCustom:label>type-Tshirt</setupCustom:label>
<setupCustom:scriptId>cseg1</setupCustom:scriptId>
<setupCustom:recordScriptId>customrecord_cseg1</setupCustom:recordScriptId>
<setupCustom:recordType internalId="487" xmlns:platformCore="urn:core_2022_2.platform.webservices.netsuite.com">
<platformCore:name>type-Tshirt</platformCore:name>
</setupCustom:recordType>
<setupCustom:fieldType>_listRecord</setupCustom:fieldType>
<setupCustom:isInactive>false</setupCustom:isInactive>
<setupCustom:showInList>false</setupCustom:showInList>
<setupCustom:hasGLImpact>true</setupCustom:hasGLImpact>
<setupCustom:description>this would qualify as the tshirt type i select on my vendor bill</setupCustom:description>
<setupCustom:isMandatory>false</setupCustom:isMandatory>
</record>
</readResponse>
</getResponse>
</soapenv:Body>
Upvotes: 1
Views: 560
Reputation: 23
I found the solution for this problem. In order to receive values for a custom segment from NetSuite, first we send a getCustomizationId
request to NetSuite. For a custom segment, the response looks like this:
{
"nullFieldList": null,
"label": "type-Tshirt",
"scriptId": "cseg1",
"recordScriptId": "customrecord_cseg1",
"recordType": {
"name": "type-Tshirt",
"internalId": "487",
"externalId": null,
"type": null
},
"fieldType": "_listRecord",
"isInactive": false,
"showInList": false,
"filteredByList": null,
"hasGLImpact": true,
"help": null,
"description": "some description",
"isMandatory": false,
"defaultSelection": null,
"internalId": "5"
}
Then we need to perform a search
operation in the following format:
cRef = new CustomizationRef();
cRef.scriptId = 'customrecord_cseg1'; //recordScriptId from above response
cRef.internalId = 487; //recordType internal id from above response
crsb = new CustomRecordSearchBasic();
crsb.recType = cRef;
crs = new CustomRecordSearch();
crs.basic = crsb;
s = new SearchRequest();
s.searchRecord = crs;
response = NetSuiteSoapService.search(s);
The result of this search will include the values for the custom segment.
Upvotes: 1