Event Parameters Mail Script

Ken83
Mega Guru

Hello Community,


        I'm using an event to trigger an email notification. I'm calling this event from within a workflow Run Script activity. I have pulled values in the workflow and written them to the workflow scratchpad. In the Run Script activity, I have created variables containing the scratchpad values. The 2 values are sys_ids for users. When I pass these values into the event, I need to then use them in a mail_script and I currently cannot do that. Is this even possible?


I read this and it looks like this would work, except it doesn't...

The event parameters are



1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Your second option is the correct syntax.



Just to be clear, does the parameter contain just the user's sys_id or does it contain 'User sys_id'? What happens when you add the following logging in?



var userID = event.parm1; //this should be just a sys_id


gs.log('---->User ID from event.parm1: ' + userID);


var gr2 = new GlideRecord('sysapproval_approver');


gr2.addQuery('approver', userID);


gr2.addQuery('state', 'requested');


gr2.query();


gs.log('---->Number of rows returned: ' + gr2.getRowCount());


while(gr2.next()){


  gs.log('---->Approval for: ' + gr2.sysapproval.getDisplayValue());


}


View solution in original post

10 REPLIES 10

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You should be able to accomplish that, could you post your run script activity and mail script?


RUN SCRIPT...



var user = current.variables.requested_for;


workflow.scratchpad.user = user;


var manager = user.manager;


workflow.scratchpad.delegate = manager;



gs.eventQueue("user.disabled",current,user,manager);



MAIL SCRIPT...



gs.log("MAIL SCRIPT IS RUNNING");



var gr2 = new GlideRecord('sysapproval_approver');


gr2.addQuery('approver', ${event.parm1});


gr2.addQuery('state', 'requested');


gr2.query();


while(gr2.next()){


  gs.log("gr2.sysapproval");


}


Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't believe you need the ${} in the mail script. event should just be a javascript object you can access.


I did that same script without the ${} around event.parm1 and still nothing. Tried it with quotes and still nothing. It is running the script though. Just not getting anything back.