- 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-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-09-2023 10:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 10:49 PM
did you check what came in logs?
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 11:53 PM
Hi @Ankur Bawiskar
I already fix it, but I can't get into the space 😅
It's not aligned
I tried to add the template.space(4); here, but it will show the true and false variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:35 AM
I already fix it. Remove the all template.space(4); to the script.