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.

Customize approval emails with requested item variables

Chris135
Giga Contributor

Hello everyone,

I am trying to customize an approval email notification with variables from a requested item. I modified the requested_items_summary_with_options email script with the requested item's sys_id. I then called the mail script in the notification email but the variables show up blank when the manager receives the email.

Here is the notification data I am putting in the body:

 

${mail_script:requested_items_summary_with_options}
 
Requesting User: ${variables.requested_for}

Request Type: ${variables.request_type}

Report Title: ${variables.report_title}

Description of Report: ${variables.description_of_report}

Urgency: ${variables.urgency}

Requested Due Date: ${variables.requested_due_date}

${mail_script:approval_items_summary}

${sysapproval.description}

${mailto:mailto.approval}

${mailto:mailto.rejection}

Click here to view ${sysapproval.sys_class_name}:  ${sysapproval.URI}

 

The mail_script approval items are showing up as intended, but the variables from the requested item are not. I tried creating an email template and importing that but I achieved the same results. I attached some screenshots to help provide clarity. Any and all help is greatly appreciated. Thank you for your time!

From,

Chris

1 ACCEPTED SOLUTION

Also Can you replace setReqwuestID line with 

set.setRequestID(current.getValue('sysapproval'));

View solution in original post

11 REPLIES 11

dvp
Mega Sage

In the email script

Please update the line

item.addQuery('request', current.sysapproval)

to

item.addQuery('sys_id', current.sysapproval);

Chris135
Giga Contributor

Hello dvp,

Thank you for your response. When I updated that line with 'sys_id', it inputs a new line but does not fill in the variables. It now displays:

 

Summary of Requested items:
RITM0010729: 1 X Informatics Report at $0.00 each 
Options:

Requesting User:

Request Type:

Report Title: 

Description of Report:

Urgency: 

Requested Due Date: 

Summary of Requested items:

Click here to approve RITM0010729

Click here to reject RITM0010729

Click here to view Requested Item:  LINK

 

I updated the line with 'sys_id' and the actual sys_id of the requested item. When using the actual sys_id for the requested item, it shows the same 'RITM0010729: 1 X Informatics Report at $0.00 each ' line and also shows the price for each informatics report in a long list.

Also Can you replace setReqwuestID line with 

set.setRequestID(current.getValue('sysapproval'));

Chris135
Giga Contributor

Thank you dvp. That did work, but it now shows all the variables for the form. Is there a way for me to specify only certain variables to be shown in the email? Would I specify those in the email script?