Dot walk from sysapproval to 'on behalf of' in email notification

Keith Morgan2
Mega Contributor

Hello,

I am working on updating the approval request email notification that goes out to the relevant approver. This particular version is used for Service Catalogue items.

I am currently unable to dot walk from the [sysapproval_approver] table to get the name of the person the catalogue item has been ordered on behalf of. I can easily get who opened the request, but I need the name of the user in the 'Request For' part of the request.

This is currently causing an issue where approvers are being asked to approve requests for the person who opens the ticket, and not who the item is for.

Can anyone please assist?

Thanks in advance

 

2 ACCEPTED SOLUTIONS

Change the above script to below:

var result; //**
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
if(gr.next()){
result = gr.sysapproval.request.requested_for.getDisplayValue();
template.print(result);
}

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

Keith Morgan2
Mega Contributor

Thanks Prateek! Whilst that works, I adapted your answer to add it within the notification itself, without the need for the email script.

${sysapproval.request.requested_for}

This worked like a charm. Thank you for you help 🙂

View solution in original post

4 REPLIES 4

Prateek kumar
Mega Sage

You can write a email script to pull the values

var result; //**
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
if(gr.next()){
result = gr.sysapproval.variables.Your_requested_for_variable_name;
template.print(result);
}

https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_automatingapps_madr...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Keith Morgan2
Mega Contributor

Thanks for your quick response, Prateek.

I can get the variable data easily - I use the variable 'business justification' in the email body. Whilst there is a requested for variable on the catalogue item, not all items use this. I need to reference the actual field within the actual REQXXXXXXX to ensure I can provide the most robust information.

I hope this makes sense

 

Change the above script to below:

var result; //**
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
if(gr.next()){
result = gr.sysapproval.request.requested_for.getDisplayValue();
template.print(result);
}

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Keith Morgan2
Mega Contributor

Thanks Prateek! Whilst that works, I adapted your answer to add it within the notification itself, without the need for the email script.

${sysapproval.request.requested_for}

This worked like a charm. Thank you for you help 🙂