Add Button in Email Template and Update the Record Field Value

Create an email template using the navigation Documents > Templates > Email Templates > New.

Add a variable in the email template, which can be replaced using script.

For example:

Click JJ_YES to confirm.

Click JJ_NO to reject.

Here, JJ_YES and JJ_NO can be replaced using replace() in the script.

Using script, this variable can be replaced, and using HTML tags, add a button to the template using script and add an anchor tag to specify the link to the required record.

JJ_YES: ‘<a href=”https://5432341-sb1.app.netsuite.com//app/site/hosting/scriptlet.nl script=1440&deploy=1&response=yes&recordId=’ + recordId + ‘”>YES</a>’

JJ_NO: ‘<a href=”https://5432341-sb1.app.netsuite.com//app/site/hosting/scriptlet.nl?script=1440&deploy=1&response=no&recordId=’ + recordId + ‘”>NO</a>’

In the URL given, the tag <a> will redirect to the corresponding record using a Suitelet Script. In the Suitelet script, load the record and set the value of the field that needs to be updated.

For example:

let billPaymentRecord = record.load({

        type: record.Type.VENDOR_PAYMENT,

        id: recordId,

        isDynamic: true

      });

      billPaymentRecord.setValue({

        fieldId: ‘custbody_jj_charity_response’, 

        value: response

      });

      billPaymentRecord.save();

The URL can be divided into three parts. The first part is the corresponding Suitelet script internal URL that can be used to access and test your Suitelet content. The second part is the response, based on the response, the corresponding field value will be updated. The third part is the record ID. Add the record ID to redirect to the respective record.

Leave a comment

Your email address will not be published. Required fields are marked *