How to hide add/remove all from the multirow variable set

nikhitha24
Tera Guru

Hi Team,

 

Can someone please help me on the below issue.

How can we remove the add / remove all and actions from the table it is multirow variable set.

nikhitha24_0-1704274664806.png

 

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @nikhitha24 

 

These 2 links will be helpful. 

 

https://www.servicenow.com/community/itsm-forum/hide-disable-add-remove-all-x-buttons-on-a-multi-row...

 

https://www.servicenow.com/community/developer-articles/disable-buttons-in-multirow-variable-set/ta-...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG 

I have tried the above code still i am not able to remove the Actions please refer the below image.

nikhitha24_0-1704287963640.png

 

Script:

function onLoad() {
    //MRVS is loaded after the form is loaded. Hence setting a delay of 2 secs.
    setTimeout(function() {
        disableButtons();
    }, 2000);
}

function disableButtons() {
  var mrvsid = '50bc13ad1b69f5107222ebd6ec4bcbae';//sys_id of MRVS
  if(window == null){//Service Portal
 
    //hide Add button on MRVS
    this.document.getElementById(mrvsid + '_add_row').style.display = 'none';
   
    //hide Remove All button on MRVS
    var mrvs = g_form.getField("snapshot_change");//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';
            //If you want to disable the button, but still show it, then use below line instead.
            //btn[i].disabled="disabled";
        }
    }
    var y = this.document.getElementsByClassName("btn btn-sm icon-cross multi-row-delete-row");
// alert(y.length);
var j;
for (j = 0; j < y.length; j++) {
    y[j].style.display = 'none';
}
 var icon = this.document.getElementsByClassName("wrapper-xs fa fa-close");
        //alert(icon.length);
        for (var j = 0; j < icon.length; j++) {
            //alert(icon[j]);
            if (icon[j].getAttribute("data-original-title") == 'Remove Row') {
                //alert(icon[j].style.display);
                icon[j].disabled = "disabled";
                icon[j].style.display = 'None';
            }
    }
  }
  else{//native UI method
    //hide Add and Remove All buttons on MRVS
    document.getElementById('table_variable_buttons_' + mrvsid).style.display = 'none';
    //hide only the Add button
    document.getElementById(mrvsid + 'Add').style.display = 'none';
    //hide only the Remove All button
    document.getElementById(mrvsid + 'removeAllRows').style.display = 'none';
    //hide delete and/or edit icon/button on each row of MRVS
    var mrvs = g_form.getValue('snapshot_change');
    var obj = JSON.parse(mrvs);
    for (var i = 0; i < obj.length; i++) {
      //delete - check Name, may be 'cross' instead
      document.getElementsByClassName('btn-sm multi-row-delete-row')[i].style.display = 'none';
      //edit    
      document.getElementsByClassName('btn icon-edit btn-sm')[i].style.display = 'none';
    }
  }  
}
 
 
Please help me on the below code. 

 

Hi @nikhitha24 

 

My dev use same article and it worked for them. Let me check with my team once.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************