Business rule on sys_email table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2023 03:18 AM - edited 07-18-2023 03:25 AM
Hi Team,
I want to use the event name in the business rule condition (created on sys_email table ). I'm not sure how to determine or rather dot walk the event name. Can some one please guide
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hello @Ankur Bawiskar ,
Is it not recommended to have before BR on sys_email table? we have a requirement to check the user from sys_email table and query the user table and fetch the user name then map it to user id in the sys_email. we are thinking to acheive it in before insert BR, what's your thought on this one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
please post a new question and share all the details there and tag me as this is an old thread
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2023 01:54 PM
The even name which you see there is nothing but email log from table (sys_email_log).
from BR on sys_email table, you can write following script to get event name:
var getEvent = new GlideRecord('sys_email_log');
getEvent.addQuery('email',current.sys_id);
getEvent.query();
if(getEvent.next()){
gs.addInfoMessage('Event name is '+getEvent.event.getDisplayValue());
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hello @JohnnySnow
current.event is the reference to the Event table (sysevent).
current.event.name fetches the actual event name.
Instead of creating a BR on sys_email, use one of these:
Event Script – Triggered when a specific event fires.
Script Action – Fires when an event occurs; you can check the event name and perform actions.
if (event.name == 'incident.assigned') {}
If this response proves useful, please mark it as Accept as Solution and Helpful. Doing so benefits both the community and me. 👍🙂
