I have the following script attached to a form (a sales order form).
What I want it to do is look up an addressbook record with a specific label and use that data to populate some custom fields in the sales order.
The script (below) is able to retrieve the customer record (i.e. the value of the custid variable is set) but the alines variable gets set to -1. What am I doing wrong? This customer has many addressbook entries.
var sp_Messages = ''; function sp_so_helper_pageInit(type) { sp_Messages = 'so_helper.js initn'; var custid=nlapiGetFieldValue('entity'); sp_Messages += 'entity is ' + custid + 'n'; var custo=nlapiLoadRecord('customer',custid); var alines=nlapiGetLineItemCount('addressbook'); sp_Messages += 'num address lines ' + alines + 'n'; sp_so_helper_updateScriptMessage(); } function sp_so_helper_getItemCount() { var lineNum = nlapiGetLineItemCount('item'); return lineNum; } function sp_so_helper_updateScriptMessage() { nlapiSetFieldValue('custbody_sp_scriptmessage',sp_Messages); }