Business rule to set state value if date/time field matches to currrent date/time

jjones4773
Tera Guru

I have the current situation.   I want to compare the Scheduled On date to the current date/time and when it matches or supersedes it, the state will switch to 'send-ready'.  The business rule script is below.

 

jjones4773_0-1709046488563.png

 

 

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

var gr = new GlideRecord('x_uno15_nrapp_push_notification');
gr .addEncodedQuery('scheduled_onISNOTEMPTY');
gr .query();

var scheduled = new GlideDateTime(getValue('scheduled_on'));
var nowdatetime = new GlideDateTime();

while (gr .next()) {
if (scheduled >= nowdatetime)

{
gr .setValue('state', send-ready);
gr .update();
}
}

})(current, previous);

 

Thanks.

 

Jason

1 ACCEPTED SOLUTION

Mark Manders
Tera Patron

What's your trigger? Why not create a flow for this? Put in a wait until the time you define and then let it do it's magic.

View solution in original post

2 REPLIES 2

Mark Manders
Tera Patron

What's your trigger? Why not create a flow for this? Put in a wait until the time you define and then let it do it's magic.

Because I was stuck in Business Rules - The flow designer worked because the condition has "from now" option where the business rule logic only had "ago"

 

The wait condition rule that worked was 'scheduled_on' relative before 1 min from now.