- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 01:08 AM
Hi All,
I have few checkbox on catalog task form. Where assign to person has to check those boxes if user has returned those items.
The checkbox which are true needs to be shown on notification. Attaching the screenshot for reference:
So in the notification it should come as:
Hardware Returns:
Mobile Phone,
Bag/Pack
Can anyone help??
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 04:01 AM
since your notification is on sc_task
use this
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery("sys_id", current.request_item);
reqitem.query();
if(reqitem.next()) {
template.print("Hello3");
// add here logic to check variable value is true then only print
}
I already shared link for solution above
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
‎02-16-2022 03:26 AM
Hi,
in email script you cannot determine which variable was visible and which was hidden as that part works on client side
what you can do is check variable is of type checkbox and if true then print it
If my response helped please mark it correct and close the thread so that it benefits future readers.
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
‎02-16-2022 03:44 AM
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery("sys_id", current.sys_id);
template.print("Hello");
reqitem.query();
template.print("Hello2");
while(reqitem.next()) {
template.print("Hello3");
Note - I don't know I'm trying to see the issue the step by step. This hello 3 is not printing. Do you know the reason?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 04:01 AM
since your notification is on sc_task
use this
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery("sys_id", current.request_item);
reqitem.query();
if(reqitem.next()) {
template.print("Hello3");
// add here logic to check variable value is true then only print
}
I already shared link for solution above
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
‎02-16-2022 01:17 AM
You can create a mail script where you will retrieve the variables from the cat_item (current).
if the checkbox is trued, then template print that variable.
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 04:41 AM
Hi
Please follow the steps below to achieve your requirement:
1) Navigate to Notification Script module and use the script shared below:
var table = current.getTableName();
var count = 0;
if (table == 'sysapproval_approver') {
count = 1;
} else {
for(vars in current.variable_pool){
count++;
break;
}
}
if(count > 0){
var mvalue = '';
var list = [];
var display = [];
template.print('<table border="1">');
//Query for the non-empty variables for this record
//Catalog item and task variables pull from 'sc_item_option_mtom' table
if(table == 'sc_req_item' || table == 'sc_task' || table == 'sysapproval_approver') {
var itemVars = new GlideRecord('sc_item_option_mtom');
if(table == 'sc_req_item'){
itemVars.addQuery('request_item', current.sys_id);
}
if(table == 'sc_task'){
itemVars.addQuery('request_item', current.request_item.sys_id);
}
if(table == 'sysapproval_approver'){
itemVars.addQuery('request_item', current.sysapproval.sys_id);
}
itemVars.addNotNullQuery('sc_item_option.value');
//Exclude Label and Container variables
itemVars.addQuery('sc_item_option.item_option_new.type', '!=', 11);
itemVars.addQuery('sc_item_option.item_option_new.type', '!=', 19);
itemVars.addQuery('sc_item_option.item_option_new.type', '!=', 20);
itemVars.addQuery('sc_item_option.item_option_new.type', '!=', 24);
itemVars.orderBy('sc_item_option.order');
itemVars.query();
while(itemVars.next()){
template.print("<tr>");
template.print("<td>"+itemVars.sc_item_option.item_option_new.question_text+"</td>");
mvalue = itemVars.sc_item_option.value;
// Check if the value is from the reference field
if (itemVars.sc_item_option.item_option_new.type == '8') {
var grRefTable = new GlideRecord(itemVars.sc_item_option.item_option_new.reference);
grRefTable.addQuery('sys_id',mvalue);
grRefTable.query();
if (grRefTable.next()) {
mvalue = grRefTable.getDisplayValue();
}
template.print("<td>"+mvalue+"</td>");
template.print("</tr>");
}
// Check if the type is List Collector
if(itemVars.sc_item_option.item_option_new.type == '21') {
list = itemVars.sc_item_option.value.split(',');
for(var i=0; i<list.length; i++){
var grListTable = new GlideRecord(itemVars.sc_item_option.item_option_new.list_table);
grListTable.addQuery('sys_id',list[i]);
grListTable.query();
if (grListTable.next()) {
display.push(grListTable.getDisplayValue());
}
}
template.print("<td>"+display+"</td>");
template.print("</tr>");
}
// Check if the type is Select Box
if(itemVars.sc_item_option.item_option_new.type == '5') {
var grQuestion = new GlideRecord('question_choice');
grQuestion.addQuery('question', itemVars.sc_item_option.item_option_new);
grQuestion.addQuery('value', itemVars.sc_item_option.value.toString());
grQuestion.query();
if(grQuestion.next()){
mvalue = grQuestion.getValue('text');
}
template.print("<td>"+mvalue+"</td>");
template.print("</tr>");
}
//For rest of the types
if(itemVars.sc_item_option.item_option_new.type != '21' && itemVars.sc_item_option.item_option_new.type != '8' && itemVars.sc_item_option.item_option_new.type != '5' )
{
template.print("<td>"+mvalue+"</td>");
template.print("</tr>");
}
}
}
template.print("</table>");
}
Screenshot below for reference as well:
Now once this Notification script is configured you just need to call it in your Notification which I believe you have written it on your Catalog Task Table:
Syntax for calling Notification Script in Notification is as below:
${mail_script:Mail Script Name}
This will be in the body of the notification in 3rd tab i.e. What will it Contain of Notification form
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke