NetSuite使用SOAP SuiteTalk API检索自定义段的值

huangapple go评论41阅读模式
英文:

NetSuite retrieve values of Custom Segments using the SOAP SuiteTalk API

问题

I am trying to retrieve the values of the NetSuite Custom Segments using the SOAP api. For example, considering this custom segment in NetSuite:

我尝试使用SOAP API检索NetSuite自定义段的值。例如,考虑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"
}

{
"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.

我尝试了SuiteAnswers和NetSuite SOAP指南中提到的方法,但没有成功。我感激任何帮助。

英文:

I am trying to retrieve the values of the NetSuite Custom Segments using the SOAP api. For example, considering this custom segment in NetSuite:

enter image description here

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>

答案1

得分: 1

我找到了解决此问题的方法。为了从NetSuite接收自定义部分的值,首先我们向NetSuite发送一个getCustomizationId请求。对于自定义部分,响应如下:

{
"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"
}

然后,我们需要按以下格式执行search操作:

cRef = new CustomizationRef();
cRef.scriptId = 'customrecord_cseg1'; //来自上述响应的recordScriptId
cRef.internalId = 487; //来自上述响应的recordType内部ID
crsb = new CustomRecordSearchBasic();
crsb.recType = cRef;
crs = a CustomRecordSearch();
crs.basic = crsb;
s = a SearchRequest();
s.searchRecord = crs;
response = NetSuiteSoapService.search(s);

此搜索的结果将包括自定义部分的值。

英文:

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.

huangapple
  • 本文由 发表于 2023年4月11日 02:39:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979764.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定