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
};
});
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect, or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
Do you have any other workaround on how to expose the Send Email Notification checkbox field in Workflows? Share them in the NetSuite Admin Corner.