- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 01:58 AM
Hi , i have a requirement to trigger the notifications based on the the catalog item is present in system property file
I have written a script include and calling that into the advance condition of notifications but its not working
Script include :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 10:00 PM - edited 04-05-2024 10:13 PM
Hi @avinashdube
I have updated and retested your code, and it's fine. So, you need to pass the sys_id of the record like this.
Demo Sys_Property :
Updated code :
Script include Code :
isCatalogItemIncluded: function(currentsysID) {
var listOfCatalogItems = gs.getProperty('NotificationImprovement_ListofCatlogItemtoInclude');
if (listOfCatalogItems && listOfCatalogItems.includes(currentsysID)) {
return true;
}
return false;
},
Based on the return value, you can use this code in a notification script like this :-
var answer = false;
var catalogItemId = current.variables.cat_item.toString();
var checker = new CatalogItemInclusionChecker();
var isItemIncluded = checker.isCatalogItemIncluded(catalogItemId);
if (isItemIncluded) {
if (current.priority == 1) {
answer = true;
}
}
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 02:36 AM
Hi @avinashdube ,
First of all when do you want to trigger the notification?
If you want to trigger it when a service request is opened, then you have configure the notification event properly.
- Create a new notification.
- Table = Requested Item [sc_req_item]
- Send when = event is fired
- Event name = sc_req_item.inserted
- Then in the Advanced condition, write the following script
var gr = new GlideRecord('sys_properties');
gr.addQuery('value',current.cat_item.sys_id);
gr.query();
if(gr.next())
return true;
return false;Here the value field is the sys_id of the record object added in the system properties.
You don't need the script include or business rules.
Let me know if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 02:54 AM
thanks for the reply ,
I have created system property and added the catalog item id in that
how will this gliderecord fetch that
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 10:00 PM - edited 04-05-2024 10:13 PM
Hi @avinashdube
I have updated and retested your code, and it's fine. So, you need to pass the sys_id of the record like this.
Demo Sys_Property :
Updated code :
Script include Code :
isCatalogItemIncluded: function(currentsysID) {
var listOfCatalogItems = gs.getProperty('NotificationImprovement_ListofCatlogItemtoInclude');
if (listOfCatalogItems && listOfCatalogItems.includes(currentsysID)) {
return true;
}
return false;
},
Based on the return value, you can use this code in a notification script like this :-
var answer = false;
var catalogItemId = current.variables.cat_item.toString();
var checker = new CatalogItemInclusionChecker();
var isItemIncluded = checker.isCatalogItemIncluded(catalogItemId);
if (isItemIncluded) {
if (current.priority == 1) {
answer = true;
}
}
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna