4

Is it possible to temporarily change the system date in NetSuite for purposes of testing date triggered scripts? If not is there a way to overload all NetSuite date functions so that a future or past date could be simulated for a given user in the sandbox?

We have email notifications that are sent based on the number of days before a certain NetSuite record expires. Rather than make the users wait for several days to go by to test this feature or change expiration date of records I want to provide a UI to allow the NetSuite system date to be changed.

I'd prefer the date override to be specific to the user and not for the entire sandbox instance so more than one user can simulate future/past dates. The date override would need to work in both client and server SuiteScript code as well as scheduled scripts.

Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
  • Thank you for the creative answers to date. All good but no perfect solution yet. I'm thinking out loud here but with JavaScript I'm wondering if it's possible to overwrite the prototype for date functions (or does JS disallow that) and put special logic checking for debug mode, if debug mode adjust date using an offset variable otherwise get date as normal. – Rich Bianco Oct 01 '15 at 14:04

3 Answers3

2

A possible workaround is create two script parameters. A checkbox to indicate the script is in debug mode and a debug date where you can specify any date you want.

Then on your script, check if the checkbox is checked. If it is checked use the value in the date parameter for the comparison instead of the system date.

Rusty Shackles
  • 2,802
  • 10
  • 11
  • this is what I am thinking but this would not allow for scheduled scripts to fire. I am thinking you could have a similar design and use a workflow or other user event script that calls the scheduled script based on the timing. Would need to test that out more to confirm – TMann Sep 05 '15 at 14:30
  • I like this too. For scheduled scripts maybe I'd have to add a parameter to pass in a testing date/time. Does JavaScript allow changing the prototype for system date functions? If so, that could be done and logic to determine whether the real date or simulated date is returned. This might not even work depending on how NS fires scheduled scripts. Is there anyone who hated NetSuite (development) but then learned to like it? – Rich Bianco Oct 01 '15 at 14:11
2

You can create a deployment parameter field {testDays}.

In production make it zero. In Test environment give it some negative numbers.

create something like the following

newTempDate = nlapiAddDays({expirydate}, {testDays})

and use the newTempDate for your criteria everywhere.

Faz
  • 160
  • 1
  • 1
  • 11
1

I'm not sure of the availability of such a functionality in Netsuite that allows you to customize the System Date. As far as I'm concerned, your schedule scripts will always pick timestamp of the server instance. No matter if you change your date / timezone, all your transactions, records, scripts & login times will display Pacific time, where the server computer is located.One solution could be defining your own Date in your script instead changing the server date (In case you don't want to change the date in your record) and validate your records against it.

Rockstar
  • 2,228
  • 3
  • 20
  • 39