The script in the reply section is supposed to add...
# suitescript
l
The script in the reply section is supposed to add a button that when clicked will print a custom pdf from a suitelet. But the button doesn't appear at all on the invoice. Could not figure out why.
/** * @NApiVersion 2.x * @NScriptType ClientScript * @NModuleScope SameAccount */ define(['N/currentRecord', 'N/record', 'N/url'], function(currentRecord, record, url) { function pageInit(context) { var form = context.form; var printButton = form.addButton({ id : 'custpage_print_invoice', label : 'Print Invoice', functionName : 'onPrintInvoiceButtonClick' }); printButton.isDisabled = true; var invoiceRecord = currentRecord.get(); if (invoiceRecord && invoiceRecord.getValue('status') === 'Open') { printButton.isDisabled = false; } } function onPrintInvoiceButtonClick() { var invoiceRecord = currentRecord.get(); var invoiceId = invoiceRecord.getValue('id'); var invoiceType = invoiceRecord.getValue('recordType'); var suiteletUrl = url.resolveScript({ scriptId : 'customscript3856', deploymentId : 'customdeploy1', params : { invoiceId : invoiceId, invoiceType : invoiceType } }); window.open(suiteletUrl, '_blank'); } return { pageInit : pageInit, onPrintInvoiceButtonClick : onPrintInvoiceButtonClick }; });
b
take a look at the console
you should be getting an error about calling a method on undefined
r
You will be only getting the button in edit mode I believe, not in view mode. For the button to appear in view mode you need to use before load user event.
l
Thank you both. I'll try that.