Set up Model Object Schedule from Logic

Model Object can be scheduled to be recalculated periodically. This schedule can be set either manually via front-end on Model Object detail page, or set up via logic code.

You will need to acquire reference to model object, and then set the schedule.

Groovy
def schedCtx = model.schedulesContext()

schedCtx.newSchedule('myNewSchedule')
  .setStartDate(api.parseDateTime("YYYY-MM-dd'T'HH:mm:ss", '2023-05-03T10:30:42'))
  .setPeriod(7, PeriodUnit.DAY)
  .setAction('doSomething')
  .addOrUpdate()

The smallest period unit to use is a day.


References: