Solution
A Netsuite Email template using HTML. This is being send as email body on PO.
When link is clicked, suitelet is called to perform the action.
<html><head></head><body>
<p><span style="font-family:NotoSans,sans-serif;">Hi ${transaction.entity},</span></p>
<p><span style="font-family:NotoSans,sans-serif;">Please click on the following link to acknowledge your <strong>Purchase Order ${transaction.tranid} </strong></span></p>
<#assign poId=transaction.id/><#assign suiteletURL='https://4856011.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=939&deploy=1&compid=4856011&h=c2ea2fc0f271f10e569a' + '&po_id=' + poId/>
<p><span style="font-family:NotoSans,sans-serif;"><a href="${suiteletURL}">Click here to acknowledge the Purchase Order</a></span></p>
<p><span style="font-family:NotoSans,sans-serif;">Thank you</span></p>
</body></html>
Suitelet Code
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*
* * MegaResistors-USA-NS
* MEGR-128: PO Acknowledgement solution
* ***************************************************************
*
* Author: Jobin and Jismi IT Services
* Date Created: 3/5/2023
* Description: This script is used to handle the acknowledgement link click and update the corresponding PO as acknowledged by vendor
*
* REVISION HISTORY
* @version 1.0: MEGR-128: This script is used to handle the acknowledgement link click and update the corresponding PO as acknowledged by vendor
*/
define(['N/record', 'N/ui/serverWidget'],
/**
* @param{record} record
*/
(record, serverWidget) => {
/**
* Defines the Suitelet script trigger point.
* @param {Object} scriptContext
* @param {ServerRequest} scriptContext.request - Incoming request
* @param {ServerResponse} scriptContext.response - Suitelet response
* @since 2015.2
*/
const onRequest = (scriptContext) => {
try {
if (scriptContext.request.method === 'GET') {
const form = serverWidget.createForm({
title: ' ',
});
let alert = form.addField({
id: 'custpage_alert',
type: serverWidget.FieldType.INLINEHTML,
label: 'Alert'
});
alert.defaultValue = '<script>alert("Thank you! Your PO has been acknowledged successfully");window.close();</script>';
const poId = scriptContext.request.parameters.po_id
if (poId) {
//set 'Purchase Order Acknowledged by Vendor' to checked
record.submitFields({
type: record.Type.PURCHASE_ORDER,
id: poId,
values: {
'custbody_jj_po_acknldge_vend_megr128': true
},
options: {
ignoreMandatoryFields: true
}
});
}
scriptContext.response.writePage(form);
}
} catch (e) {
//set error message to the PO field
record.submitFields({
type: record.Type.PURCHASE_ORDER,
id: poId,
values: {
'custbody_jj_err_email_snding_megr128': e.message
},
options: {
ignoreMandatoryFields: true
}
});
log.error("Err@request", e.message)
}
}
return {
onRequest: onRequest,
}
});