Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

use random variable in email notification

Bradley Bush
Mega Sage

Hi, I have a custom notification that goes out to the "requested for" when the request is closed. In the request, seven variables are displayed one at a time based on another variable selection. The displayed variables are controlled by catalog UI policies and are only viewable on tasks. I need to have that random variable captured by the notification and sent to the "requested for" once the request is closed. Any help would be great, thank you.

Notification message:

BradleyBush_0-1713476459558.png

"Please select your MUV access." is a select box with seven options viewable all.

"Please select the correct AD group based on access requested/given:" is a label with seven checkboxes only viewable to one group on the task level.

BradleyBush_1-1713476542728.png

 

1 ACCEPTED SOLUTION

@Bradley Bush 

 

Try with below logic inside the mail script :

 

var ritmGr = new GlideRecord('sc_req_item');
    ritmGr.addQuery('sys_id', current.sys_id);
    ritmGr.query();
    if (ritmGr.next()) {
var num1 = ritmGr.variables.muv_selectbox_access.getDisplayValue();
template.print("test: "+num1);
}

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

Hi Amit, thank you very much:)