Some customers have requested to expose the Send Email Notification checkbox field in Workflows through Enhancement ID: 238550 Workflow Manager > If “Give Access” checkbox in employee record is set to true, set “Send notification Email” checkbox to true. This is generally to make it easier for NetSuite Admins by reducing a step in the onboarding process.
While this feature is not yet available in NetSuite, a workaround is possible using SuiteScript. The sample code below can be deployed to achieve this functionality:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/currentRecord'],
/**
* @param{currentRecord} currentRecord
*/
function(currentRecord) {
/**
* Function to be executed when field is changed.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.sublistId - Sublist name
* @param {string} scriptContext.fieldId - Field name
* @param {number} scriptContext.lineNum - Line number. Will be undefined if not a sublist or matrix field
* @param {number} scriptContext.columnNum - Line number. Will be undefined if not a matrix field
*
* @since 2015.2
*/
function fieldChanged(scriptContext) {
var rec = scriptContext.currentRecord;
var fieldId = scriptContext.fieldId;
if(fieldId === 'giveaccess'){
if(rec.getValue(fieldId) === true){
rec.setValue({
fieldId: 'sendemail',
value: true
});
}
}
}
return {
fieldChanged: fieldChanged
};
});

