Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
ClientServerTimeService - small class to work with server-synched time on the client
I have many client operations that need to be time-synched with the server.
I started having code littered all over the place and decided to wrap it up into a neat little object.
Here is the first pass of this class (and some usage examples):
/** * Small class that will attempt to deliver the server time on the client. * Pretty narrow scope, basically only usefull in my SuiteLets. The SuiteLet * adds a hidden text field that will have the server time set just before * the response is returned. Then on the client side when this class is instantiated * it will read the server time from the hidden field and calculate the differential. */ function ClientServerTimeService() { var _serverTime = DateUtils.CreateDateFromMilliseconds( nlapiGetFieldValue(ClientServerTimeService.SRVR_TIME_FLD_ID)); var _serverLocalDifferential = _serverTime.getTime() - new Date().getTime(); /** * Returns the calculated server time based on the server-set Steve Klett | Senior Developer
NetValue Technology
0