Generate Expense Report PDF to File Cabinet

I’m trying to generate Expense Report PDF to File Cabinet by SuiteScript 1.0

function main() {
var filters = new Array();
filters[0] = new nlobjSearchFilter('type', null, 'is', 'ExpRept');
filters[1] = new nlobjSearchFilter('mainline', null, 'is', 'T');
var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid');
columns[1] = new nlobjSearchColumn('tranid');
columns[2] = new nlobjSearchColumn('entity');
var searchresults = nlapiSearchRecord('transaction', null, filters, columns);
for (var i = 0; searchresults != null && i < searchresults.length; i++) {
var file = nlapiPrintRecord('transaction', searchresults[i].getValue('internalId'), 'PDF', null);
file.setName(searchresults[i].getValue('internalid') + searchresults[i].getText('entity') + ".pdf");
return JSON.stringify(searchresults);

Code above return error “UNEXPECTED_ERROR” without details.

It works fine with Type = CustInvc

Would anyone guide me how to generate Expense Report PDF to File Cabinet?

Thank you so much.

Rookie Asked on February 14, 2020 in SuiteScript.
Add Comment
1 Answer(s)

You probably want to first identify where the error is occurring – does it let you search the record and fails on “nlapiPrintRecord”, or does it get to there and fails on “nlapiSubmitFile”, etc. Once you know what specifically is failing, you can troubleshoot further – for example, if the searchRecord is what’s failing, you can try re-creating the search in the user interface to figure out what filter/column is breaking it.

Rookie Answered on February 14, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor