我正在尝试在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.
答案 0 :(得分: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;
}
}