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

Is this approval notification for only single catalog item or all the catalog items?

 

Chris135
Giga Contributor

The approval would only be for a single catalog item. The manager wants customized notifications so she can see what the variables are in the form in the email before she logs into ServiceNow. 

I am assuming that I would specify the variables I want to see in the email script? Maybe in this line?

while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.cat_item.price.getDisplayValue() + " each <br />");

I tried replacing the item.number with variable.requesting_user but it did not work.

Thank you again for all of your assistance?

If we talking about 2-3 fields then I would just add it in the if contions

 if(vs.get(i).getLabel() != '' && vs.get(i).getLabel() == 'YOUR_LABEL_NAME1' && vs.get(i).getLabel() == 'YOUR_LABEL_NAME2' ) {

 

If you more than that and you foresee that more variables can be added to it. Then I would create a system property and call it in the script

Chris135
Giga Contributor

That worked perfectly. Thank you for all of your help dvp. I greatly appreciate it!

You are welcome 🙂