Gaston Mosteiro
09/09/2024, 8:10 PMCeligo AI
09/09/2024, 8:10 PMAI generated answer (using internal Slack threads):To print a PDF for a transaction record using a custom button and advanced/basic PDF template, you can follow these steps: 1. Create a Suitelet script that will generate the PDF. This Suitelet will use the
N/render
module to generate a PDF from a transaction record using a specific template. Here is a sample code snippet:
javascript
var render = require('N/render');
var record = require('N/record');
function suitelet(context) {
var recId = context.request.parameters.recId;
var recType = context.request.parameters.recType;
var transactionRecord = record.load({
type: recType,
id: recId
});
var renderPDF = render.transaction({
entityId: recId,
printMode: render.PrintMode.PDF,
inCustLocale: true
});
context.response.writeFile(renderPDF);
}
2. Create a custom button on your transaction record. This can be done by going to Customization > Forms > Transaction Forms
, then select your form and go to Screen Fields > Main
. Here you can add a new button.
3. Add a client script to your transaction form that will call the Suitelet when the custom button is clicked. Here is a sample code snippet:
javascript
function onButtonClick() {
var recId = nlapiGetRecordId();
var recType = nlapiGetRecordType();
var suiteletURL = nlapiResolveURL('SUITELET', 'customscript_yoursuitelet', 'customdeploy_yoursuitelet');
suiteletURL += '&recId=' + recId + '&recType=' + recType;
window.open(suiteletURL);
}
Remember to replace 'customscript_yoursuitelet'
and 'customdeploy_yoursuitelet'
with your actual Suitelet script ID and deployment ID.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/09/2024, 8:10 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854515493
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850276709
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846966267
Celigo AI
09/09/2024, 8:10 PM