- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 11:09 PM
Hi Guys,
I have created once email notification ,it will be triggered when task is created for my ritm.
Here I need check one condition, this email notification should be triggered to only one catalog item.
So I am trying to get catalog item name through script and filter condition,both are not working. am not getting ritm value.
As another way I tried the same in background script as well to trigger event ,from there to trigger notification ,am unable to get current task's ritm number.
Please refer my below script which I have used in both email notification and business rule.
Table name I have choosed as : sc_task
Note: The Same script works in background script
(function executeRule(current, previous /*null when async*/ ) {
var ritm,answer;
gs.log('1' + current.number);
var tab=new GlideRecord('sc_task');
tab.addQuery('number',current.number);
tab.query();
if(tab.next()){
gs.log(tab.request_item);
ritm=tab.request_item;
}
var tab1 = new GlideRecord('sc_req_item');
tab1.addQuery('sys_id', ritm);
tab1.query();
if (tab1.next()) {
gs.log('catItem' + tab1.cat_item);
if (tab1.cat_item == '03c1fe251b018414c6e62f89bd4bcb82') {
answer = true;
} else {
answer = false;
}
}
gs.log('3' + answer);
})(current, previous);
Anything wrong with my code? Can anyone help me to fix this issue?
Thanks in Advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 05:21 AM
Thanks for your suggestion guys.
I got the current task's catalog item name from below script added in advance script section ,
var answer;
if (current.request_item.cat_item.name == 'EOL') {
answer = true;
} else {
answer = false;
}
kindly ignore the first answer given by me.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 11:40 PM
Hi,
you can give this in the condition of the business rule itself; dot walk to the request_item -> cat_item -> name field and give your catalog item name
Can you share the condition of business rule here?
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
12-09-2019 12:40 AM
tried this Anukar, No luck .Notification is not getting triggered.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 12:51 AM
below one line of code will give you the cat item name
current.request_item.cat_item.getDisplayValue()
Note: make sure the catalog task is available while running the code.
can you confirm how did you setup the notification ? is it event based or record based ? what table have you selected on notification . if you have selected sc_task table as table then you dont need to write glide record here. one line of script will work here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 01:48 AM
yea Harshvardhan. I have choosed sc_task table only in both nofication and business rule.
tried to trigger based on event based and record based as well.The thing is current.request_item is empty thats why nothing is working.
Even your code returns empty only 😞