Delay the closing of the suitelet page after submission

Requirement

We need to delay the closing of the suitlet page for 3 seconds after clicking the submit button

Solution

The following code snippet can be provided at the end of the suitelet script for to wait 3 seconds for closing the suitelet window

//  Function to wait the closing of suitelt page for 3 second

                    function setTimeout(aFunction, milliseconds){
                        var date = new Date();
                        date.setMilliseconds(date.getMilliseconds() + milliseconds);
                        while(new Date() < date){
                        }

                        return aFunction();
                    }
                    setTimeout(function(){ log.debug('Ran after 3 second'); }, 3000);


                    var htmlCode = '<html><body><script type="text/javascript">window.close()</script></body></html>'

Leave a comment

Your email address will not be published. Required fields are marked *