- 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 11:49 PM
Hi Ankur,
Thanks for replying! Its hidden on form as well as on RITM. Hope you would be able to help me on this requirement.
Regards,
Jitendra Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 11:55 PM
As I mentioned this cannot be done.
The server side script won't know what's hidden/shown on RITM form.
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 11:56 PM
I believe I have answered your original question so please mark my response as correct and helpful and close the question
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-05-2021 02:54 AM
Hi Ankur,
Below Script correctly work with catalog task group assignment notification, however, it doesn't work with request submitted notification. Can you please help what is wrong here?
template.print("<b>Summary of Requested items:\n</b>");
var item = new GlideRecord("sc_req_item");
if (item.get(current.request_item.sys_id)) {
template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id); set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getDisplayValue() != '') {
template.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}
}
Here is an example,
Regards,
Jitendra Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2021 03:07 AM
Would you mind marking my response as correct and helpful.
I have answered your original question which was notification on sc_request.
Also I could see you are not using the script I shared in your recent script and image.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader