- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 07:45 AM
Hi All,
I want to include Request Item summary in the Request submitted notification to user. Currently it include only Req data like below. Now we need include variable information in the same email. Please suggest how we can do that?
I am using email notification
Your request has been received
Click here to view request: ${URI_REF}
Request Category: ${mail_script:print_category}
Request Subcategory: ${mail_script:print_subcategory}
Requested For: ${requested_for}
Opened: ${opened_at}
${mail_script:print_cat_item_request_submitted}
Thanks and Regards,
Jitendra Singh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 07:57 AM
You need to use email script in your email body and include it in email
Mail script: print_cat_item_request_submitted
Script
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', current.sys_id);
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 07:57 AM
Hi
You can use the notification script to Glide to RITM table with query containing parent as current REQ sys_id and get the variables data from RITM record and call the notification script via ${mail_script:your_notification_script} in REQ email notification body.
follow this for notification scripts Email notification scripts
Please mark my answer as helpful/correct, if applicable.
Best Regards,
Sai Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 07:57 AM
You need to use email script in your email body and include it in email
Mail script: print_cat_item_request_submitted
Script
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', current.sys_id);
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 10:13 AM
Hi Ankur,
Thank You! Its pretty close. I just have one issue. I have some variables hidden on catalog form which I don't want to show up on email. Is that possible anyway?
Regards,
Jitendra Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 09:40 PM
Glad to know what it worked.
the script I shared is server side and you won't know whether it was hidden on form or not in RITM.
Not possible as of now.
If my response helped please mark it correct and helpful and close the question
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader