通过SuiteScript获取客户的送货地址和帐单邮寄地址

问题描述 投票:1回答:1

我试图在SuiteScript中获取客户的默认送货地址和帐单地址。

    var shipaddress = null;
    var billaddress = null;

    //Find the default billing and shipping addresses
    var add_Count = customerRec.getLineCount('addressbook');
    for (var i = 1; i <= add_Count; i++){
        customerRec.selectLine('addressbook', i);
        var def_Bill = customerRec.getCurrentSublistValue('addressbook', 'defaultbilling');
        var def_Ship = customerRec.getCurrentSublistValue('addressbook', 'defaultshipping');
        if(def_Bill){
            billaddress = customerRec.getCurrentSublistSubrecord('addressbook', 'addressbookaddress');
        } else if(def_Ship){
            shipaddress = customerRec.getCurrentSublistSubrecord('addressbook', 'addressbookaddress');
        }
    }

使用此代码,我可以获得第一个,但一旦它命中

customerRec.selectLine('addressbook', i);

它第二次抛出错误。

SSS_INVALID_SUBLIST_OPERATION
You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.
suitescript2.0
1个回答
0
投票

我找到了答案。请看下面。

var add_Count = customerRec.getLineCount('addressbook');
for (var i = 0; i < add_Count; i++){
    var def_Bill = customerRec.getSublistValue('addressbook', 'defaultbilling', i);
    var def_Ship = customerRec.getSublistValue('addressbook', 'defaultshipping', i);
    var anAddress = customerRec.getSublistSubrecord('addressbook', 'addressbookaddress', i);
    if(def_Bill){
        billaddress = anAddress;
    } else if(def_Ship){
        shipaddress = anAddress;
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.