Friday, February 22, 2019

Determine the Liability Account's Internal ID of a Payroll Item


On a Payroll Item search, the Liability Account is returned as a text field. Thus, we cannot determine the Internal ID of this account. Since the Liability Account (ID: acctnumber) is a scriptable field on the Payroll Item (as indicated on the SuiteScript Browser), the solution is to retrieve the search result's ID and load the Payroll Item. Once the record is loaded, use the getFieldValue method to pull up the Liability Account's Internal ID.

This sample snippet demonstrates how you can do this via scripting:

var records = nlapiSearchRecord('payrollitem', 'customsearch91');  // perform the Payroll Item search
var id = records[0].getId();
var payrollitem = nlapiLoadRecord('payrollitem', id); // load the Payroll Item
var liabilityacct = payrollitem.getFieldValue('liabilityaccount'); // use getFieldValue method to retrieve Liability Account's Internal ID

No comments:

Post a Comment