Hi all. I posted this in the advancedpdf group, bu...
# suitescript
j
Hi all. I posted this in the advancedpdf group, but maybe this is a better place, as there are suitescript questions also. I'm trying to create my own custom PDF report for a Bill Of Materials. I want to create a custom button on the "work order" form that will trigger a call to a suitelet (see below). This is partially working now. I am able to call the suitelet and populate my custom PDF that is located in the file cabinet ('SuiteScripts/Advanced PDF Forms/custtmpl_ssww_bom_template.xml') . The only problem is that it does not include the associated assembly record for the work order. Can anyone provide some insight as to how to "attach" the assembly record to the workorder record. This was modeled from our knowledgeable friend. @michoel
Copy code
/**
 * Suitelet to print Work Order
 *
 * Script ID: customscript_ssww_print_workorder_sl
 * Script Type: Suitelet
 *
 */

function print_workorder(request, response) {
  try {
    var id = request.getParameter('custom_id');
    if (!id) {
      response.write('custom_id parameter missing');
    }

    var record = nlapiLoadRecord('workorder', id);
    var renderer = nlapiCreateTemplateRenderer();
    var template = nlapiLoadFile('SuiteScripts/Advanced PDF Forms/custtmpl_ssww_bom_template.xml');
    renderer.setTemplate(template.getValue());
    renderer.addRecord('record', record);
    var xml = renderer.renderToString();
    var pdf = nlapiXMLToPDF(xml);
    response.setContentType('PDF', 'print_workorder.pdf', 'inline');
    response.write(pdf.getValue());
  } catch (err) {
    response.write(err + ' (line number: ' + err.lineno + ')');
    return;
  }
}