- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 10:10 PM
Hello everyone,
Anyone can help me about Notification email script for variable on a specific catalog item?
Also, only the TRUE variables from that requested item show up in an approval notification.
I have this script, but this is for all catalog items.
template.print(' Details:<br />');
var keys = [];
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sysapproval.sys_id);
set.load();
var vs = set.getFlatQuestions();
template.space(4);
template.print(' ' + 'Title: ' + " = " +current.sysapproval.variables.u_requested_for.title+ '<br />');
template.space(4);
template.print(' ' + 'Department: ' + " = " +(current.sysapproval.variables.u_requested_for.department).getDisplayValue()+ '<br />');
template.space(4);
template.print(' ' + 'Country: ' + " = " +current.sysapproval.variables.location.country+ '<br />');
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + '<br />');
}
}
I want this to a specific catalog item and displays true variables only.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 09:50 PM
like this
template.print(' Details:<br />');
var keys = [];
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sysapproval.sys_id);
set.load();
var vs = set.getFlatQuestions();
template.space(4);
template.print(' ' + 'Title: ' + " = " +current.sysapproval.variables.u_requested_for.title+ '<br />');
template.space(4);
template.print(' ' + 'Department: ' + " = " +(current.sysapproval.variables.u_requested_for.department).getDisplayValue()+ '<br />');
template.space(4);
template.print(' ' + 'Country: ' + " = " +current.sysapproval.variables.location.country+ '<br />');
for (var i = 0; i < vs.size(); i++) {
var label = vs.get(i).getLabel();
var variableName = vs.get(i).getName();
var variableValue = vs.get(i).getDisplayValue();
gs.info(variableValue + " name is " + variableName);
if(label !='' && variableName !='' && variableValue.toString() == 'true')
template.space(4);
template.print((label + ' : ' + variableValue) + '<br />');
}(current, template, email, email_action, event);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2023 01:28 AM
you are already handling this in your email script
if(label !='' && variableName !='' && variableValue.toString() == 'true')
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 06:24 PM
Hi @Ankur Bawiskar ,
I'm not sure if I done it right.
Here's the original requested item approval email for all request items.
I exclude the new request item (Cloud Services Internal User Menu Access) here.
Sys ID is not "........"
Here's the approval email I created for that specific request item.
Sys ID is "......."
Then here's the original notification email script for all requested item
Here's the notification email script I created for that specific item.
I tried to submit a request and check the email logs.
The approval email still captured the existing notification.
How can I make the Cloud Item Approval Requested captured to this catalog item: Cloud Services Internal User Menu Access?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 07:56 PM
@Ankur Bawiskar @Ravi Chandra_K ,
I already fix the notification
But the email body is still showing the "false" items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 08:51 PM
are you sure you are calling the correct email script from email body?
also did you check by adding gs.info()
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 08:56 PM