Events not triggering within a business rule

matthew_hughes
Kilo Sage

I've created the below business rule where I'm trying to generate two events. I'm wanting it to trigger when records within the 'x_lbg_group_recert_grp_recertification' get created on the current date:

matthew_hughes_1-1745911261844.png

matthew_hughes_2-1745911299199.png

 

My two events are:

matthew_hughes_5-1745911546208.png

 

The records are being created via a Scheduled Job. However what I'm finding that even though there are records that are being created today, it's not generating the two events:

matthew_hughes_3-1745911380936.png

matthew_hughes_4-1745911460642.png

 

So I was just wondering if anyone knows what I'm doing wrong so that I can generate the two events

 

 

 

 

 

17 REPLIES 17

Devi D
Tera Expert

@matthew_hughes You are checking "Created on Today"  , but in a "before insert in business rule " , the created field is still null(it hasn't been saved yet). 

 

so the condition created on today fails.

 

so you can use the script instead of filter condition something like this

 

(function executeRule(current, previous /*null when async*/) {

   var today = new GlideDate();
   var createdDate = current.sys_created_on.getDate();

   if (createdDate == today.getDate()) {
       gs.log("Event 1 triggered for group manager: " + current.group_manager);
       gs.log("Event 2 triggered for line manager: " + current.line_manager);

       gs.eventQueue("lbg.group.recert.group.manager", current, current.group_manager, current.recertification_quarter);
       gs.eventQueue("lbg.group.recert.line.manager", current, current.line_manager, current.recertification_quarter);
   }

})(current, previous)

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

Would you mind closing your earlier questions by marking appropriate response as correct?

How to amend the Feedback widget on the portal 

Members have invested their time and efforts in helping you.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

you are creating records via scheduled job

Is that BR initial logs coming?

Why not directly send email from Notifications using Inserted checkbox?

Why are you using Business rule?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Shree_G
Kilo Sage

@matthew_hughes ,

 

Created field is updated after the form is submitted, Therefore, you are checking before insert and Created on today would not work. Instead use Flow designer with "Record" created trigger and fire events as below:

 

Shree_G_1-1745913303793.png

 

Shree_G_0-1745913289088.png

 


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.