Search code examples
netsuitesuitescript2.0

Processing \Animation in NetSuite


I have this client script which copies the line number entered in Copy line# and creates new lines from number of lines entered in Copy #Times. This thing takes time when you increase the number of lines you require to copy. So can we give any processing animation till all the lines are set so user dont have to worry?copy line

I have tried giving dialog.create but it didnt work. I want the animation to stay until script is executing and after that stop.

var options = {
                    title: 'Alert',
                    message: 'Processing. Please wait.',
                     buttons: [{
                     label: 'OKK...',
                     value: 1
                     },
                     ]
                    };
                    dialog.create(options).then(success)
                    return (true);

success is a function I am calling.


Solution

  • The N/ui/dialog module is intended for showing dismissable messages, and won't really work for progress bars as you cannot hide the buttons, nor close it via code. I would recommend looking at a third party library. A very popular one is SweetAlert2, and there is some sample code on the NetSuite Professionals site for using it with NetSuite.

    If you just want a quick hack, you could just used the Ext.js library that NetSuite includes by default on all pages. However I would highly recommend not doing so for any production code because NetSuite could update or remove it at any time in a future upgrade.

    var messageBox = Ext.MessageBox.show({
      title: 'Lines are being copied...',
      msg: 'This may take a couple minutes',
      wait: true,
      width: 250
    });
    
    // your work here
    
    messageBox.hide()