Business Rule against sys_email never fires off.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:03 AM - edited 02-19-2025 11:03 AM
I am trying to create a business rule to do something with an email after it is created (inserted) and I do not know what I am doing wrong but the BR never seems to fire off. It is like it is just ignored completely like it doesn't exist.
I created a very simple BR that on insert into sys_email set the body of the email to 'This is a test' and that never happens.
Table: Email [sys_email]
Application: Global
Active: Checked
Insert is checked
Actions: Set field values [Body] to 'this is a test....'
that is it, very simple test and it just never does it. What am I missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:39 AM
(function executeRule(current, previous /*null when async*/) {
var caseID = current.instance;
if(caseID) {
var caseRecord = new GlideRecord('sn_hr_core_case_benefits');
if(caseRecord.get(caseID)) {
var serviceid = caseRecord.getValue('sys_created_by');
current.setValue('body', 'test...' + current.target_table + '-' + current.instance + '-' + caseRecord.getValue('sys_id'));
} else {
current.setValue('body', 'nothing found...' + current.target_table + '-' + caseID);
}
} else {
current.setValue('body', 'nothing 1 found...' + current.target_table + '-' + caseID);
}
})(current, previous);
Could you please try this script, let me know if it works?
If you believe the solution provided has adequately addressed your query, could you please **mark it as 'Helpful'** and **'Accept it as a Solution'**? This will help other community members who might have the same question find the answer more easily.
Thank you for your consideration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 08:10 AM
I don't see what you did different here? I know i left out the (current, previous) in my copy/paste.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 08:22 AM
I modified the variable c which was not defined; it should be caseRecord.
Did it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 09:46 AM
oh. I mean it never even gets to that point.
it acts like the caseRecord.get(caseID) record doesn't exist but it clearly does because I can take the case.instance ID and go look it up in the table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:43 AM
after insert BR on sys_email should work. I have used it recently.
did you just try by adding gs.info() and see if BR triggered?
BR is in which scope?
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