When building a NetSuite SuiteApp, you may have noticed the following error occur when deploying to a different NetSuite account in a different timezone:
"An error occurred during custom object creation. Details: This event recurrence is invalid because it only has one recurrence time and it must have either none or at least two."
Why does this happen?
By default, NetSuite treats your XML definition of a "starttime" for any scheduled script in UTC time.
In the XML definition for the scheduled script, you may have something like this:
- <starttime>08:00:00Z</starttime>
This is telling NetSuite that 08:00:00 in UTC time will be converted to the company's timezone when they install or update the SuiteApp. For example, 08:00:00 becomes 09:00:00 if the company timezone is GMT (BST/UTC+1).
This only really happens if you have a big gap between the recurrence of the scheduled script. For example, if your repeat for the scheduled script is set to every 6 hours.
NetSuite requires that the recurrence has at least 2 times of when it can execute in a single day. However, if the "starttime" has been converted from UTC to a different timezone, the "starttime" could end up being something like 23:00. This means NetSuite will not get a chance to run the recurrence of the script before it reaches the next day. This is what causes the error mentioned previously.
How do I fix it?
It's quite simple! Just remove the "Z" from the "starttime" so it looks like the following:
- <starttime>08:00:00</starttime>
This tells NetSuite to not convert the start time of the deployment and keep it as 08:00:00 across all accounts, regardless of the timezone the company is in. This gives NetSuite a chance to run the script at least 2 times in a single day.