Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to convert onload client script into widget

Donabelle
Tera Contributor

Hello team, I want to move/convert my onload client script to widget since DOM Manipulation is not a best practice to use in client script. I want to hide the buttons and icons in my MRVS, this script is working but not advisable to use in client script. Can someone help me convert this into widget?

 

      // for (i = 0; i < btn.length; i++) {
                //     if (btn[i].innerText == 'Add') {
                //         // btn[i].disabled="disabled";
                //         //If you want to hide it fully, then use below line.
                //         btn[i].style.display = 'None';
                //     }
                // }
                // var btn = this.document.getElementsByClassName("btn btn-default");
                // for (i = 0; i < btn.length; i++) {
                //     if (btn[i].innerText == 'Remove All') {
                //         // btn[i].disabled="disabled";
                //         //If you want to hide it fully, then use below line.
                //         btn[i].style.display = 'None';
                //     }
                // }
 
   // var sheets = this.document.styleSheets;
    // var sheet = sheets[0];
    // //This hides the row-level buttons
    // sheet.insertRule('a.fa-close { display: none !important; }');

    // var sheets = this.document.styleSheets;
    // var sheet = sheets[0];
    // //This hides the row-level buttons
    // sheet.insertRule('a.fa-pencil { display: none !important; }');
0 REPLIES 0