How we can use delay in backed of SCA

We can use the Sleep function in Suitescript to delay the code in SCA. Some examples, such as if the sales order has been created with a delay and we are planning to create a customer deposit depending on the sales order, show an error for the reference key of the sales order. In this situation, we can use the sleep function for that.

function sleep(milliseconds) {

    var date = Date.now();

    var currentDate = null;

    do {

        currentDate = Date.now();

    } while (currentDate - date < milliseconds);

}

We can call this function where we can delay. For example, we added it before the customer’s deposit creation.

Leave a comment

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