- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 12:54 PM
Hi, I am trying to trigger an event inside of a BR that will send a notification to the task primary owner if a label/tag containing "planned" is added to a VTB card on Visual Task Board. The event/email is not getting triggered whenever I make a change on the VTB. Could anyone review the following:
I set up a BR to run on vtb_card table, After, insert
My event and the notification are also running on vtb_card and the notification will get sent to the task.primary_contact.
Business Rule:
Condition: Board = Team Name
(function executeRule(current, previous /*null when async*/ ) {
var labelEntryGR = new GlideRecord('label_entry');
labelEntryGR.addQuery('table', 'vtb_card');
labelEntryGR.addQuery('table_key', current.sys_id);
labelEntryGR.query();
while (labelEntryGR.next()) {
var labelGR = new GlideRecord('label');
if (labelGR.get(labelEntryGR.label.sys_id)) {
if (labelGR.name.indexOf('planning') !== -1) {
var cardGR = new GlideRecord('vtb_card');
if (cardGR.get(labelEntryGR.table_key)) {
gs.eventQueue('myevent, cardGR);
}
}
}
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 11:07 PM
@user034972342 - Please add logger to understand the value you are receiving as a labelGR.name and check. Code looks good to me, I assume you have register the required event "myevent" on the table vtb_card.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 09:48 PM
so what debugging did you perform by adding gs.info() statements?
you are not setting the recipient from script, how is the recipient set?
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
‎04-01-2025 06:51 AM
The recipient is sent in the notification setup. When to Send - Event is triggered Who to send: Users/Groups in task.primary_contact
I added gs.info() but they are not appearing in logs.... I don;t think BR is even getting triggered
(function executeRule(current, previous /null when async/) {
gs.info("start BR: " + current.sys_id);
var labelEntryGR = new GlideRecord('label_entry');
labelEntryGR.addQuery('table', 'vtb_card');
labelEntryGR.addQuery('table_key', current.sys_id);
labelEntryGR.query();
while (labelEntryGR.next()) {
gs.info("Process label_entry record: " + labelEntryGR.sys_id);
var labelGR = new GlideRecord('label');
if (labelGR.get(labelEntryGR.label.sys_id)) {
gs.info("Found label: " + labelGR.name);
if (labelGR.name.indexOf('planning') !== -1) {
gs.info("trigger event");
var cardGR = new GlideRecord('vtb_card');
if (cardGR.get(labelEntryGR.table_key)) {
gs.info("Found VTB Card: " + cardGR.sys_id + " - Triggering event 'myevent'");
gs.eventQueue('myevent', cardGR);
} else {
gs.info("No VTB Card found for label_entry.table_key: " + labelEntryGR.table_key);
}
} else {
gs.info("Label does not contain 'planning'.");
}
} else {
gs.warn("No label found: " + labelEntryGR.sys_id);
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 11:00 PM
@user034972342 - You missed a quote in gs.eventQueue.
var labelEntryGR = new GlideRecord('label_entry');
labelEntryGR.addQuery('table', 'vtb_card');
labelEntryGR.addQuery('table_key', current.sys_id);
labelEntryGR.query();
while (labelEntryGR.next()) {
var labelGR = new GlideRecord('label');
if (labelGR.get(labelEntryGR.label.sys_id)) {
if (labelGR.name.indexOf('planning') !== -1) {
var cardGR = new GlideRecord('vtb_card');
if (cardGR.get(labelEntryGR.table_key)) {
gs.eventQueue('myevent', cardGR); // You missed a quote
}
}
}
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 06:54 AM
I added the missing quote, but still not getting triggered.