Rich Bianco
Rich Bianco

Reputation: 4174

How to set NetSuite system date in the future or past for testing?

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.

Upvotes: 4

Views: 1687

Answers (3)

Faz
Faz

Reputation: 160

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.

Upvotes: 2

Rusty Shackles
Rusty Shackles

Reputation: 2840

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.

Upvotes: 2

Rockstar
Rockstar

Reputation: 2288

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.

Upvotes: 1

Related Questions