Sunday, June 23, 2019

Send Notification Email to Administrator when new users are granted access in production account

function saveRecord(){
        var access = nlapiGetFieldValue('giveaccess');

        if(access == 'T'){
            nlapiLogExecution('DEBUG','script triggered', 'T');
            var searchresults = nlapiSearchRecord('employee','159');
            nlapiLogExecution('DEBUG','search length',searchresults.length);
            for( var i = 0; searchresults != null && i < searchresults.length; i++){
                var empEmail = searchresults[i].getValue('email');
                nlapiSendEmail('3',empEmail,'Access Granted','test access');


Where '159' is the internal ID of an employee saved search whose criteria is 'Role is Administrator' and result is 'email'.

This is may serve as alternate solution for Enhancement#261238.

No comments:

Post a Comment