- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 05:41 AM
Hello beautiful community!
I have a Business Rule that is based on sc_request for the sake of the notification.
What I need to do is to trigger it based on the choice of a certain catalog item's multiple choice variable called 'requested_resource_type'. So when the user chooses 'technical_project_resource' in 'requested_resource_type' it should trigger the notification.
Here is my BR code:
// Business Rule: Trigger Notification for teknisk_resursprojekt
// When to run: After Insert/Update
(function executeRule(current, previous /*null when async*/) {
// Kontrollera om cat_item har rätt sys_id
if (current.cat_item == '0f0278598c2a1e10ebb6ef259418f246') {
// Hämta relaterade sc_req_item-poster
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while (gr.next()) {
// Kontrollera om användaren valt "technical_project_resource" i variabel 'requested_resource_type'
var selectedResources = gr.variables.requested_resource_type; // Variabelvärde
if (selectedResources && selectedResources.indexOf('technical_project_resource') !== -1) {
// Trigga eventet 'teknisk_projektresurs'
gs.eventQueue('teknisk_projektresurs', 'custom@email.com', current.requested_for.email, '');
}
}
}
})(current, previous);
The problem; is that it doesn't trigger anything. The requested_for should have gotten the email, but nothing is sent. I've tested with my own custom email in the eventQueue line, but it doesn't trigger to that one either.
What am I doing wrong? Here is the configuration for the BR:
Here is the configuration for the notification:
Thanks in advance! 😎
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 05:53 AM
your BR script is wrong
update as this ->you should query RITM to get the catalog item name
(function executeRule(current, previous /*null when async*/ ) {
// Kontrollera om cat_item har rätt sys_id
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', current.sys_id);
if (ritm.cat_item == '0f0278598c2a1e10ebb6ef259418f246') {
// Kontrollera om användaren valt "technical_project_resource" i variabel 'requested_resource_type'
var selectedResources = ritm.variables.requested_resource_type; // Variabelvärde
if (selectedResources && selectedResources.indexOf('technical_project_resource') !== -1) {
// Trigga eventet 'teknisk_projektresurs'
gs.eventQueue('teknisk_projektresurs', current, 'custom@email.com', ritm.requested_for.email);
}
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 07:11 PM
then event should trigger
Did you check any error when event triggered?
eventQueue link looks fine to me
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:03 AM
Instead of Current you can use "null".