How to Add a Client Script Progress Bar
Hi, does anyone have any tips on how to add a progress bar to a client script? Basically, when a button is clicked on the form, it triggers code that takes a while. I just need a progress bar to indicate the script is still running. It doesn’t even need to show an exact percentage of completion, just something to show it’s running.
Hi @Luci4, Please help this one.
This is possible, we created loading page and percentage of completion for a custom process in sales order.
Thank you!
It is doable via DOM manipulation by adding some css elements on page load via client script which is ready to execute upon button clicked or something. Make sure that you run it asynchronously for some reason that browser will freeze when processing large data.
I like the javascript approach. Use your favored javascript library to show a progress bar / loader. Since I still had it setup in a test account , here is an example using Sweet Alert 2 (https://sweetalert2.github.io/). Sweet Alert 2 isn’t a progress bar library, but it can be abused to do so.
/** * @NApiVersion 2.x */ define(["./sweetalert2.all.js", "N/https"], function(Swal, https) { return { button: function() { Swal.fire({ onBeforeOpen: Swal.showLoading, onOpen: function() { https.get .promise({ url: "https://www.example.com" }) .then( function() { Swal.close(); }, function() { Swal.hideLoading(); Swal.update({ type: "error", text: "An error occured" }); } ); }, allowOutsideClick: false, allowEscapeKey: true, text: "I'm busy" }); } }; });
I added the above as a button function’s code using a beforeLoad user event script to avoid NetSuite trying to run sweetalert2 serverside.

Thanks for the example!