Good morning, I have a client script that calls a...
# suitescript
j
Good morning, I have a client script that calls a suitelet that does background processing. I'd like to put up a spinner or a message indicating stuff is happening. In the client script I've tried using ui.message and/or changing the cursor but the call to the suitelet (via https.post) is taking over before the message is displayed. for example:
Copy code
function onButtonClick(){
  myMsg2 = message.create({
            title: "Work Order Issue", 
            message: "Creating and Auto Allocating Work Order Issue", 
            type: message.Type.INFORMATION
        });
  myMsg2.show()
  var response = <http://https.post|https.post>({
            url: outputURL,
            body: JSON.stringify(bodyObj)
  });
}
Any ideas?
d
We use this in a client script:
Copy code
function showSpinnerAndDoLogic(spinnerHtml) {
    jQuery('#div__body').css('display', 'none');
    jQuery('body').append(spinnerHtml);
    goDoThings = function () {
        //Do some business logic here
    };
    setTimeout((function () {
        return goDoThings();
    }), 25);
};
it's basically hiding the page, showing the spinner html, and then running some logic function inside a timeout function
k
A simple solution I use when handling this sort of thing is
<http://https.post|https.post>().promise()
. In your
.then()
put
myMsg2.hide()
followed by your response message, and in your
.catch()
put
myMsg2.hide()
followed by an error message.
This allows the message to stay up while the processing happens on in the background, and takes the message down when it's done regardless of success or failure.
j
This was a big help thanks everyone!