Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to disable remove and add button on MRVS

Vinod S Patil
Tera Contributor

Hello Everyone


I need to disable multirow variable set buttons(add and remove all) edit button should be visible on RITM. I tried this by using client scrip in my pdf which applies on RITM but it is working for catalog item view not on RITM.

Please suggest on this.

 

function onLoad() {

    //Type appropriate comment here, and begin script below

    setTimeout(function() {

        disableButtons();

    }, 2000);

}

//var n = new GlideRecord('sc_req_item');

//n.query();

//while (n.next()) {

function disableButtons() {

    var mrvsid = '41226d96c32222104b501533e4013121';

    this.document.getElementById(mrvsid + '_add_row').style.display = 'none';

 

    var mrvs = g_form.getField("mrvs1"); //internal name of MRVS

    mrvs.max_rows_size = 0;

    var btn = this.document.getElementsByClassName("btn btn-default");

    for (i = 0; i < btn.length; i++) {

        if (btn[i].innerText == 'Remove All') {

            btn[i].style.display = 'None';

        }

    }

}

@Ankur Bawiskar 

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Vinod S Patil 

where you want to disable? RITM form?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

shubhamseth
Giga Sage

@Vinod S Patil Have you enabled below checkbox on Catalog Client Script? 

 

Shubham_Jain_0-1751891292458.png

 

 

 

✅ Issue resolved? → Mark as Correct


Found value? → Mark as Helpful


Not applicable

yes shubham

Anubhav24
Mega Sage

Hi @Vinod S Patil ,

I have hidden clear and delete button on my MRVS using below code , it works everywhere on catalog item view , ritm view and on portal :

I have written this code in my onload client script

    var style = top.document.createElement('style');
    style.innerHTML = '*[ng-click="c.clearValue()"],*[ng-click="c.deleteRow($index)"]{display:none;}';
    top.document.head.appendChild(style);
You can update the ng-click values accordingly .
 
Please mark correct/helpful if my response helped you.