1

IE. I implement schedule script, which contain block of statements to execute, now i need to define that the execution process need to complete within a 1:30 minute. after 1:30 minute execution should be stop and give message.

YNK
  • 109
  • 1
  • 14
  • you can use JQuery SetTimeout Function. see this http://stackoverflow.com/questions/8610272/jquery-settimeout – Akshay Tilekar Jan 03 '17 at 05:22
  • I think answer to question http://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep is what you are looking for – Kira Jan 03 '17 at 05:23
  • @AkshayTilekar Thanks for quick response, but i can't use JQuery in netsuite script. – YNK Jan 03 '17 at 05:24
  • @Kira Thanks, right now i am using that only, but looking for any other dynamic way, where i can change the time duration from outside of script, where user don't need to change within a script code. – YNK Jan 03 '17 at 05:28
  • @YNK i have posted reference links in the answer,visit it and let me know if you are done achieving it – Akshay Tilekar Jan 03 '17 at 05:35
  • 1
    You can use jQuery, and most other JS libraries, in NetSuite. jQuery is automatically accessible in Client Scripts. For other script types, you need to include the appropriate source for the library as a Library Script on your Script record. – erictgrubaugh Jan 03 '17 at 23:06

1 Answers1

3

There's currently no timeout method in Netsuite for serverside scripts. What you can do is set up a variable that holds the end time and check on it from time to time like. Something like this:

var maxExecutionTime = 90; //In Seconds
var endTime = new Date();
endTime.setSeconds(endTime.getSeconds() + maxExecutionTime);

if(new Date() > endTime){
    //exit
}
Adolfo Garza
  • 2,876
  • 10
  • 15