skip to Main Content

I am getting an error when deploying the following script

function sendSevaredentEmails(){
var sResult = new Array();
 
 sResult = nlapiSearchRecord('transaction','customsearch1899'); //load an existing transaction saved search or create a search
 
 var xml = "<?xml version="1.0"?>n<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">n";
   xml += "<pdfset>";
 
 for (var i = 0; sResult != null && i < sResult.length; i++) {
 var sColumns = sResult[i].getAllColumns();
  
  //generate invoice printout
  var pdfFile = nlapiPrintRecord('TRANSACTION', sResult[i].getValue(sColumns[0]),'PDF');
  
  //set target folder in file cabinet
  pdfFile.setFolder(483765);
  //Set Available without login to true
  pdfFile.setIsOnline(true);
  
  //store file in cabinet
  var fileID = nlapiSubmitFile(pdfFile);
  
  // load the file to get its URL
  var fileURL = nlapiLoadFile(fileID).getURL();

  var pdf_fileURL = nlapiEscapeXML(fileURL);

    xml += "<pdf src='"+ pdf_fileURL +"'/>";
 
 }
 
   xml += "</pdfset>";
   var consolidatedPDF = nlapiXMLToPDF(xml);
  
   nlapiSendEmail('-5', '[email protected]', "Subject", 'Body', null, null, null, consolidatedPDF);
}

I am getting the following error
System UNEXPECTED_ERROR 8/22/2023 5:04 pm -System- Cannot convert INVH8437 to java.lang.Integer (SYSTEM_LIBS$NSAPI$sys#758); ID: llmso2pi1v9yvv4a21klp

INVH8437 is the first invoice number returned by the saved search so I know I’m getting that far. Any help would be greatly appreciated.

2

Answers


  1. Chosen as BEST ANSWER

    I added the internal id to column 0 of the saved search and the script ran successfully!


  2. Make sure you pass the internal ID of the invoice into your nlapiPrintRecord() call, not the invoice number.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search