NetSuite:启用行项目装运(MSR)时的自定义地址字段



我对NetSuite有一个奇怪的问题。在勾选了"启用行项目运输"的销售订单上,即启用了多条运输路线,运输地址位于项目行级别。

通过SuiteScript,如果地址是从地址簿中选择的,我可以访问线路级别的地址。

然而,当该地址是动态输入的自定义地址时,我不知道如何访问beforeSubmit函数中的这些字段。

任何建议都将不胜感激!

您可以使用两个中的一个或两个以下的获取所选地址的详细信息

nlapiGetLineItemValue('item','shipaddress',1)
nlapiGetLineItemText('item','shipaddress',1)

上面只会给你地址记录的id或标签。但是,很难访问客户端的地址详细信息。

但是,使用子记录API,您可以使用子记录API:在用户事件脚本中访问服务器端的记录

var record = nlapiLoadRecord('customer', nlapiGetFieldValue('entity'),{recordmode: 'dynamic'});
//loop through all the addressbooks
if(record.getLineItemValue('addressbook', 'internalid', i) === nlapiGetLineItemValue('item','shipaddress', 1))
record.selectLineItem('addressbook', 2);
//change the sub record value
var subrecord = record.editCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
subrecord.setFieldValue('attention', 'Accounts Payable');
subrecord.commit();
record.commitLineItem('addressbook');
var x = nlapiSubmitRecord(record);

想明白了!对于那些在未来冒险来到这里的迷失灵魂:

以下是您可以在销售订单行级别上使用的函数,用于循环浏览自定义地址并提取特定信息。

希望这将在某个时候添加到NetSuite文档中。

请注意,我这样做是专门为州信息。如果您想查看还有哪些其他字段可用,请将&xml=T添加到提交的销售订单URL的末尾,并在resuling xml结构中搜索iladdrbook。它实际上被视为一个行项目。

function getCustomAddressFromLineItem(soLineNum) {
    nlapiLogExecution('DEBUG', 'Custom Address', 'Custom Address: Line # ' + soLineNum);
    var addressid = nlapiGetLineItemValue('item','shipaddress',soLineNum); // get the id of the custom address
    var customAddressesLineCount = nlapiGetLineItemCount('iladdrbook'); // get custom address book count
    nlapiLogExecution('debug', 'test', 'addressid: ' + addressid + ' -- linecount: ' + customAddressesLineCount);
    for (var i = 1; i <=customAddressesLineCount; i++)
    {
     var addressinternalid = nlapiGetLineItemValue('iladdrbook','iladdrinternalid',i); // get internal id of custom address book
     if (addressinternalid == addressid) // match it with the id of custom address being set
     {
      var addr = nlapiGetLineItemValue('iladdrbook','iladdrshipaddr1',i);
      var customState = nlapiGetLineItemValue('iladdrbook','iladdrshipstate',i); // get your state
      nlapiLogExecution('debug', 'test', 'address: ' + addr + ' -- state: ' + customState);
      return customState;
     }
    }
}

最新更新