Displaying sc_req_item variables on approval notification using sysapproval_approver table

Nicholas Hromya
Mega Guru

Hello everyone,

Now that I got the dedicated approval notification to work, how do I display specific variables from the sc_req_item table on the approval notification?

 

I found where I can get the summary of requested items using the below mail script.  This seems to get all the variables (and works).  But I need to get only five variables and my approvers want to see it in a specific table based format (fun).

 

If I was using a notification using the sc_req_item table, I would use ${variables.<variablename>}, but since I am using the sysapprover_approver table how do get these specific variables?

 

<mail_script>
template.print("Summary of Requested items:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.quantity + " X " + gr.cat_item.getDisplayValue() + " at " + gr.cat_item.price.getDisplayValue() + " each \n");
}

 

TIA

Nick

1 ACCEPTED SOLUTION

shyamkumar VK
Kilo Patron

@Nicholas Hromya ,

 

Can you Try using ${sysapproval.variables.VARIABLE_NAME} to get Variables data from RITM 

Also refer to below link which is similar to your Requirement 

 

https://www.servicenow.com/community/itsm-blog/utilizing-variable-information-in-notifications/ba-p/...

 

Regards,

Shyamkumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

View solution in original post

8 REPLIES 8

Hello @Niel5

 

Yes, that is what I was looking at as I specified in my original post as:

I found where I can get the summary of requested items using the below mail script. 

But I need a different format for managers with specific variables listed in a specific format.

Thank you.

Nick

Got what you mean. For us we exclude some known variables from displaying. Maybe you can change the conditions to ==

 

for (var i = 0; i < vs.size(); i++) {
        if (vs.get(i).getDisplayValue() != '' && vs.get(i).getLabel() != 'Request is completed' && vs.get(i).getLabel() != 'Assignment group' && vs.get(i).getLabel() != 'Assigned to' && vs.get(i).getLabel() != 'Requested For' && vs.get(i).getLabel() != 'Subject' )  {
            template.print('<tr>');
            template.print('<td style="width: 70%; height: 13px;"><span style="font-family: verdana, geneva; font-size: 8pt;">' + vs.get(i).getDisplayValue() + '</span></td>');
            template.print('</tr>');
        }

 

 

shyamkumar VK
Kilo Patron

@Nicholas Hromya ,

 

Can you Try using ${sysapproval.variables.VARIABLE_NAME} to get Variables data from RITM 

Also refer to below link which is similar to your Requirement 

 

https://www.servicenow.com/community/itsm-blog/utilizing-variable-information-in-notifications/ba-p/...

 

Regards,

Shyamkumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Nicholas Hromya
Mega Guru

@shyamkumar VK 

Whoohoo!! That worked!

Thank you!

Nick