Friday, November 9, 2018

How to prevent the standard email notification to be sent out when a task record is created from a workflow using a User Event Script.

How to prevent the standard email notification to be sent out when a task record is created from a workflow using a User Event Script.

Workflows are sometimes used to create a task record based on a business process that is being implemented. When creating the task record, the 'Send Email' checkbox is ticked by default. So if a task record is created through a workflow, it would automatically send the standard notification that a task record has been assigned.

For those that wants to prevent the notification from being sent and instead send a customized email through the workflow, we can stop it by using a User Event script. The user event script needs to be deployed on a task record and triggered on 'Before Record Submit'. Please see sample script below.

function beforeSubmit(type){
    // Sample Script is set to prevent the notification if task record is created on the server side
    if (nlapiGetContext().getExecutionContext()=='userevent'){
        if (type=='create'){
            nlapiSetFieldValue('sendemail','F');
        }    
    }
}

No comments:

Post a Comment