is there a way to show a loading spinner to show t...
# suitescript
a
is there a way to show a loading spinner to show that a suitelet is processing data and have something show while that is happening? i.e. My suitelet is approving journal entries, and there are a bunch, so would like to show a spinner of some sort…is there anything native in NS for this?
j
My approach here has evolved over time. The most important thing to do is prevent the user from making the request multiple times (i.e. by clicking the button again before the first request has returned).
I usually would find the button html using js and set the
disabled
attribute. Then I would fade / hide the button and put a
div
over just the button that acted as a spinner. I can share that
div
template.
My current thinking is to just set a boolean flag in the script at the start of the processing function that acts as a sempahore to prevent the function from executing concurrently. This is simpler than disabling the button.
c
an alternative approach ive seen/used is to not let a suitelet sit and process. Save the data off to a file and let another process pick it up. Then there's no need for the spinner.
j
I also think instead of finding the button, I can just put a div over the whole page that intercepts click events, and put a loading widget in the middle of it.
An alternative to a loading spinner entirely is a message you can display using
N/ui/message
. Then you hide the message when your suitelet is done.
c
also that
j
@creece Lol I picked that up from you actually. Imo problem with saving a file and then processing later is the user doesn't get any feedback of when the process is done / if it ever succeeded / were any problems
E.g. a suitelet that takes some data and makes a new record. User usually wants to press submit and have that take them to the new record. Not sit around and find out if it got made later.
c
yeah i should prob clarify that it depends on your use case
you can have the script email as well... lots of options
a
for our use case, the
div
covering the page method seems like it makes the most sense @jkabot
we don’t want the user to navigate away from the suitelet, as it is being used for a few different things, so it would be complete, and the user would be redirected back to the suitelet to continue working.
j
the library that @battk linked in the other thread looks like it has a page blocking spinner built into it if you ever needed your own spinner, it's pretty simple https://jsfiddle.net/k7Lryc69/
c
from a design standpoint, you also dont want your users sitting on a page for a min or 2
its not always avoidable though in netsuite
a
@creece agreed, but #netsuite
c
yep