- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2020 10:22 PM
Hello Experts,
I have a catalog item with check boxes and when ever there is a notification sent for approval i want to checked values to be displayed and ignore false values.
Thank You In advance.
Solved! Go to Solution.
- Labels:
-
Service Level Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 09:51 AM
Hi Rachel,
Can you share what values/checkbox user has selected?
Still not getting why if statements are required; the below script should show only those checkboxes which are selected/true
(function runMailScript(current, template, email, email_action, event) {
var ritmSysId = current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();
var vs = set.getFlatQuestions();
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();
if(label !='' && variableName !='' && variableValue.toString() == 'true')
template.print(label + ' : ' + variableValue);
})(current, template, email, email_action, event);
this would print like this
Approve Quotes : True
Read only : True
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-23-2020 10:43 PM
Hi Ankur,
But i still see False Values
Below is the modified script :
(function runMailScript(current, template, email, email_action, event) {
var ritmSysId = current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if (vs.getLabel() != "APT None" && vs.getDisplayValue() != " none" && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + "APT None" + vs.get(i).getDisplayValue() + "none");
}
else if(vs.getLabel() != "APT Create/Edit Contract" && vs.getDisplayValue() != " create_edit_contact" && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + "APT Create/Edit Contract" + vs.get(i).getDisplayValue() + "create_edit_contact");
}
else if(vs.getLabel() != "APT Review/ Approve Contract" && vs.getDisplayValue() != " review_approve_contact" && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + " APT Review/ Approve Contract" + vs.get(i).getDisplayValue() + "review_approve_contact");
}
else if(vs.getLabel() != "APT Read Only Contract" && vs.getDisplayValue() != "read_only_contarcts" && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + "APT Read Only Contract" + vs.get(i).getDisplayValue() + " read_only_contarcts");
}
else if(vs.getLabel() != "Apttus Lock User" && vs.getDisplayValue() != "lock_user " && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + "Apttus Lock User" + vs.get(i).getDisplayValue() + "lock_user");
}
else if(vs.getLabel() != "Apptus Unlock User" && vs.getDisplayValue() != "appttus_unlock_user" && vs.getDisplayValue()== 'true' ) {
template.print(vs.get(i).getLabel() + "Apptus Unlock User" + vs.get(i).getDisplayValue() + " appttus_unlock_user");
}}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 11:20 PM
Hi,
small mistake in my script;
instead of vs.getDisplayValue() == 'true'
use vs.get(i).getDisplayValue() == 'true'
instead of vs.getLabel() use vs.get(i).getLabel()
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-23-2020 10:44 PM
Please check and let me know if i need to add or missed anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 06:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:37 PM
Hi Rachel,
Are you iterating over each variable of type checkbox?
gs.info('Question Text: '+ vs.get(i).getLabel()); // this would give you variable text
gs.info('Question Name: ' + vs.get(i).getName()); // this would give you variable name
gs.info('Question Value: '+ vs.get(i).getDisplayValue()); // this would give you that variable value
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
(function runMailScript(current, template, email, email_action, event) {
var ritmSysId = current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();
var vs = set.getFlatQuestions();
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();
if(label !='' && variableName !='' && variableValue.toString() == 'true')
template.print(label + ' : ' + variableValue);
})(current, template, email, email_action, event);
this would print like this
Approve Quotes : True
Read only : True