Hi,
solution with spel:
mod file:
MODIFY chg POST_VALIDATE z_blackout() 1337 FILTER (EVENT("INSERT"));
spl file:
chg::z_blackout() {
string wrkshft_schedule;
duration is_blackout;
date blackout_end;
wrkshft_schedule = (string)expand("&{'blackout' = wrkshft.sym->sched}");
if (is_empty(wrkshft_schedule)) {
logf(ERROR, "Unable to fetch workshitf");
return;
}
is_blackout = workshift_abs2work(wrkshft_schedule, (date)now(), (date)((int)now()+60));
if ((int)is_blackout < 30) {
blackout_end = workshift_work2abs(wrkshft_schedule, (date)now(), (duration)5);
logf(ERROR, "Unable to create COs within blackout window. Blackout will end at [%s]", (date)blackout_end);
set_error(1);
set_return_data(format("Unable to create COs within blackout window. Blackout will end at [%s]", (date)blackout_end));
}
}
You shoud create "blackout" workshift with blackout schedule, script will fetch it using Workshift name.
This code is not tested but should work
This method could be more flexible if you publish new attribute in Change Category table to maintain individual schedules for specified categories.
Regards,
cdtj