0

我对 NetSuite 有一个奇怪的问题。在已选中“启用行项目运输”的销售订单上,这意味着启用了多个运输路线,送货地址位于项目行级别。

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

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

任何指针将不胜感激!

4

2 回答 2

0

弄清楚了!对于那些未来在这里冒险的迷失灵魂:

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

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

请注意,我是专门为状态信息执行此操作的。如果您想查看可用的其他字段,请添加&xml=T到提交的销售订单 URL 的末尾并iladdrbook在生成的 xml 结构中搜索。它实际上被视为一个订单项。

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;
     }
    }
}
于 2015-12-22T18:22:58.130 回答
0

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

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);
于 2015-12-11T14:31:04.933 回答