The CreatorCon Call for Content is officially open! Get started here.

How to stop running business rule on specific period of time

Supriya25
Tera Guru

Hi Team,

 

we have two business(insert, update operation) , which plays major role in daily activity.

This two Business rules should work only between morning 6AM-afternoon 3PM.  after 3PM/before 6AM if any insertion/updating happens on record these BR's should not respond..

 

Every day we can't deactivate/Activate , so How can we achieve it ? any possibility ?

16 REPLIES 16

I'm trying in Scoped Application


var schedule = new GlideSchedule("090eecae0a0a0b260077e1dfa71da828"); 8-5 working days sys-id I took
if (schedule.isInSchedule(new GlideDateTime(gs.nowDateTime()))) {

}

Error coming system giving nowDateTime() not allowed in Scoped application

 

 

Try just

if (schedule.isInSchedule(new GlideDateTime())) {

It's returning UTC time value but I'm looking at EST timezone value validation.

 

I tried below , but it's always entering into false.

var now= new GlideDateTime();

var nowDate = new GlideDateTime(now.getDisplayValueInternal());
var schedule = new GlideSchedule("090eecae0a0a0b260077e1dfa71da828"); 8-5 working days sys-id I took
if (schedule.isInSchedule(nowDate)) {
gs.info('It is in Schedule');
}else{

gs.info('It is Not in Schedule ');

}

always returning ' It is Not in Schedule  ' 

Ahh, yes, dates are a pain:

 

if (schedule.isInSchedule(new GlideDateTime().getDisplayValue())) {

 

the "getDisplayValue" will get the date/time in the User's timezone.

if (schedule.isInSchedule(new GlideDateTime().getDisplayValue())) {

system giving Error Message : in Scoped Application  'String' value not allowed schedule.isInSchedule(string)