- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2020 11:15 AM
Hi,
I have one catalog item named as xyz which contains workflow name as yz. When user raised a request it will be go for the user's manager approval. In the approval email few fields are need to visible.
Approval email is sending for sysapprover table. Could anyone please help on this.
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 08:24 AM
Hi,
I didn't get.
Since user has filled 10 variables those 10 will come in email.
Why to display only 5 variables? are you saying you want to keep specific variables only and exclude some 5?
if yes then try this
ensure you give valid variable names in the if condition
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Summary of requested item: <br/>');
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.sysapproval);
ritm.query();
if(ritm.next()){
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();
var name = question.getName();
if(name != 'variable1' && name != 'variable2' && name != 'variable3' && name != 'variable4' && name != 'variable5'){
if(label != '' && value != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
}
}
})(current, template, email, email_action, event);
})(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
11-10-2020 08:24 AM
Hi,
I didn't get.
Since user has filled 10 variables those 10 will come in email.
Why to display only 5 variables? are you saying you want to keep specific variables only and exclude some 5?
if yes then try this
ensure you give valid variable names in the if condition
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Summary of requested item: <br/>');
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.sysapproval);
ritm.query();
if(ritm.next()){
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();
var name = question.getName();
if(name != 'variable1' && name != 'variable2' && name != 'variable3' && name != 'variable4' && name != 'variable5'){
if(label != '' && value != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
}
}
})(current, template, email, email_action, event);
})(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
09-20-2023 10:52 PM
Hello @Ankur Bawiskar ,
- Can we just show only variables that are visible on the RITM form including "Rich text" fields?
- Can we hide fields on emails that are hidden based on conditions on RITM or on catalog items?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 10:18 AM
Hi Ankur,
It is working fine. I have one small doubt.
We are populating the cmdb ci name to the catalog form by creating the reference field in the catalog form. Here I want to populate the status of the cmdb in the notification.
Is it possible to achieve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 08:27 PM
Hi Arun,
I believe your original question for showing variables in email is answered.
Can you please mark my response as correct and helpful so that this thread is closed and benefits others.
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
11-10-2020 08:28 PM
Hi,
yes you can show by checking if the variable is referring to cmdb_ci and then dot walk and get status
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader