0

I have a quirky issue with NetSuite. On a Sales Order which has 'Enable Line Item Shipping' checked, meaning Multiple Shipping Routes are Enabled, the shipping address goes on the item line level.

via SuiteScript, I can access the address on the line level IF it is selected from the address book.

However, when that address is a custom address that is entered on the fly, I have no idea how to get to those fields in a beforeSubmit function.

Any pointers would be much appreciated!

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

選択したアドレスの詳細は、以下のいずれかまたは次の 2 つを使用して取得できます。

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 に答える