-1

I'm new to SuiteScript, and I have a requirement to automatically change the value of a field, if a certain date and time is reached.

E.g., when start date and start time arrives, change the value to 'on-going'. When the end date and end time arrives, change the value to 'finished'.

What's the best way to approach this?

I am thinking about creating a scheduled script programmatically to run on the start date/time and end date/time, just to update the field. However, I don't think it is possible to programmatically set a date/time for a scheduled script.

1 Answers1

2

You can create and maintain two body fields on the record

  • Start Date containing the start date
  • End Date containing the End date

You can then use a scheduled script that runs every day. Just check the date and compare it with today's date. If matched, change the status accordingly.

Since you are specifying a time as well you can schedule the script to run up to once every 15 minutes and search for records where the start or end date time has passed and that have the wrong value. You are not going to get reliable by the minute updates anyway because of how all scheduled activity is queued but this will have your values not too far out.

bknights
  • 14,408
  • 2
  • 18
  • 31
Sayeesh
  • 208
  • 1
  • 3
  • 13
  • Yes, I think the main limitation for this is the time as it wouldn't be real-time updates. But I guess, that is the only way. Thank you – migsmagbits Sep 22 '21 at 22:21