RE: 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.setFolder(14); file.setName(searchresults[i].getValue('internalid') + searchresults[i].getText('entity') + ".pdf"); nlapiSubmitFile(file); } 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.
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.