- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:00 AM
Hello All,
I am using my OOB notification "Approval request" which creates a email when there is an approval for my RITM (catalog item). Currently I have added some messages in notification body along with that I want all my catalog item variables in my notification body which the user has selected while submitting the request. I tried setting using email script but it was not working as expected. I am not able to see any variables in notification body.
Can anyone help me on this email scripting..Thanks in advance...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:26 AM
Hi @Ashwin Perumal1 ,
Create an email script with the below code -
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();
if (label != '' && value != '') {
template.print(label + " = " + value + "<br/>");
}
}
}
Call the email script in your notification - ${mail_script:email_script_name}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:26 AM
Hi @Ashwin Perumal1 ,
Create an email script with the below code -
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();
if (label != '' && value != '') {
template.print(label + " = " + value + "<br/>");
}
}
}
Call the email script in your notification - ${mail_script:email_script_name}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:26 AM
Thanks a lot .It worked perfectly as expected. But one thing is there any possible way we can increase the font size. I want my variables alone to be displayed in a little bigger font. Any possible way we can change the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:40 AM