- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:35 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 08:42 PM
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
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:45 PM
Hello @Nicholas Hromya ,
you can use the following syntax if you queried over an sc_req_item record to retrieve variables.
var riGr = new GlideRecord('sc_req_item');
riGr.query();
while(riGr.next()){
var myVarDisplayValue = riGr.variables.my_var_name.getDisplayValue();
var myVarTechValue = riGr.variables.my_var_name.toString(); // .getValue(); might not work in scoped apps
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 03:27 PM
Hello @Malte_K
Darn, that didn't work.
My sc_req_item variable is "description_body"
My mail script (called bulletin_desc_body) is in the body of the notification as
Description: ${mail_script:bulletin_desc_body}
The Description: shows up, but not the variable.
I set the above script (bulletin_desc_body) as:
(bolded parts are from when you click "New" within the Notification Email Scripts app from navigator to create email scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 11:35 PM
Hi @Nicholas Hromya ,
maybe my example was a bit too generic. I just wanted to show how to get variables if you have a requested item [sc_req_item] GlideRecord.
In the mail script you showed, maybe try the following:
template.print("Summary of Requested items:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
var label = gr.variables.description_body.getLabel();
var description = gr.variables.description_body.getDisplayValue();
template.print(gr.number + ": " + label + ": " + description + "\n"); // Will create one row for each requested item
// Format <RITM_NUMBER>: <VARIABLE_LABEL>: <VARIALBE_CONTENT>
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 04:14 PM
Hi Nick, maybe you can start to look at the mail script "requested_items_summary_with_options".