Sunday, May 12, 2019

Get General Ledger Values using SuiteScript

Accessing GL Impact (screenshot below) values via suitescript, can be done by following the sample suitescript code below.

Please note the values retrieved are read only, similar to accessing the GL Impact from the UI.

Screen Shot


 

Sample Code

var filters = new Array();var columns = new Array();filters[0] = new nlobjSearchFilter('internalid', null, 'anyof', '1356'); columns[0] = new nlobjSearchColumn('account');columns[1] = new nlobjSearchColumn('debitamount');columns[2] = new nlobjSearchColumn('creditamount');columns[3] = new nlobjSearchColumn('posting');columns[4] = new nlobjSearchColumn('memo');columns[5] = new nlobjSearchColumn('entity');columns[6] = new nlobjSearchColumn('department');columns[7] = new nlobjSearchColumn('class');columns[8] = new nlobjSearchColumn('location');var gl_Record = nlapiSearchRecord('transaction', null, filters, columns);//var cols = new Array();var account = new Array();var debit = new Array();var credit = new Array();var posting = new Array();var memo = new Array();var name = new Array();var department = new Array();var class_category = new Array();var location = new Array(); for ( var i = 0; i < gl_Record.length; i++) { account[i] = gl_Record[i].getText(columns[0]); //use getText to get the text value of a select type field or a field that has both the debit[i] = gl_Record[i].getText(columns[1]); credit[i] = gl_Record[i].getValue(columns[2]); posting[i] = gl_Record[i].getValue(columns[3]); memo[i] = gl_Record[i].getValue(columns[4]); name[i] = gl_Record[i].getValue(columns[5]); department[i] = gl_Record[i].getValue(columns[6]); class_category[i] = gl_Record[i].getValue(columns[7]); location[i] = gl_Record[i].getValue(columns[8]);}var x = 0;

 

No comments:

Post a Comment