How we can restrict the page is not responding message from suitelet form

In client script, create an inline html filed to show the Gif lmage

 let form = createForm();

            form.clientScriptFileId = 8936;

            var progressBarField = form.addField({

                id: ‘custpage_progress_bar’,

                type: ‘INLINEHTML’,

                label: ‘Progress bar’

            });

            var loadingUrl = “https://td2921864.app.netsuite.com/core/media/media.nl?id=8959&c=TD2921864&h=l8a3m8scwi5MYaEN04g0ElFMBTV4tvnpcuwVwRhRyrWzN6Od”;

            var html = “<div><img id=’custpage_load_img’ style=’height:100px;width:150px;top: 50px;left: 600px;float: left;position: absolute;display: none;’ src='” + loadingUrl + “‘/></div>”;

            progressBarField.defaultValue = html;

In Suitelet, set to this Gif image when load and process the records

 function giveAccessBulkPage() {

        try {

            var selectedEmployees = getSelectedEmployees();

        if (selectedEmployees.length > 0) {

                console.log(“inside selected employees”, “inside selected employees”);

                jQuery(“#custpage_load_img”).css(“display”, “block”); // Show loading GIF

                const suiteletUrl = url.resolveScript({

                    scriptId: ‘customscript_jj_sl_bulk_emp_portal_acces’,

                    deploymentId: ‘customdeploy_jj_sl_bulk_emp_portal_acces’

                });

                // Array to hold all the promises

                const promises = selectedEmployees.map(function (employee) {

                    return new Promise(function (resolve, reject) {

                        https.post.promise({

                            url: suiteletUrl,

                            body: JSON.stringify({ employees: [employee] }), // Pass current employee in an array

                            headers: {

                                ‘Content-Type’: ‘application/json’

                            }

                        }).then(function (response) {

                            console.log(“response”, response);

                            if (response.code === 200) {

                                resolve(response);

                            } else {

                                console.log(“response code is not success”, “response code is not success”);

                                reject(new Error(“Response code is not 200”));

                            }

                        }).catch(function (error) {

                            console.log(“Error in HTTP request”, error);

                            reject(error);

                        });

                    });

                });

                // Wait for all promises to complete

                Promise.all(promises).then(function () {

                    // All requests completed successfully

                    console.log(“All requests completed successfully”);

                }).catch(function (error) {

                    // Handle errors here

                    console.error(“Error in processing requests”, error);

                    alert(“Error in processing requests”);

                }).finally(function () {

                    // Hide the loading GIF after all requests complete, regardless of success or failure

                    jQuery(“#custpage_load_img”).css(“display”, “none”);

                    alert(“Portal access has been provided to the selected employees.”);

                    location.reload();

                });

            } else {

                alert(“Please select at least one line from the sublist”);

                return true;

            }

        } catch (e) {

            console.log(“error @giveAccessBulkPage”, e);

            jQuery(“#custpage_load_img”).css(“display”, “none”);

        }

    }

Leave a comment

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