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.

Hide x in mrvs

SS1510
Tera Contributor

I want to hide 'X' in MRVS on on Load , the script available on community is not working .Does anyone have idea about it.

1 ACCEPTED SOLUTION

@SS1510 

this worked for me in onLoad client script on sc_req_item Table

Ensure "Isolate Script" = False for your client script

If this field is not on form then from list make it false

function onLoad() {
    //Type appropriate comment here, and begin script below
    setTimeout(function() {
        var items = document.getElementsByClassName('btn icon-cross btn-sm multi-row-delete-row');
        for (var i = 0; i < items.length; i++)
            items[i].style.display = 'none';
    }, 3000);

}

AnkurBawiskar_0-1750755155975.png

 

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

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

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@SS1510 

you will have to use DOM manipulation only, no other way to do this

check these links

Disable buttons in MultiRow Variable Set 

Only want Edit option and hide remaining all buttons in pre-populated Multi Row Variable set 

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

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

@Ankur Bawiskar  I have tried this, but not working for ''x'' icon

@SS1510 

please share your script and client script config screenshots.

You want this on RITM form right?

Also did you ensure "Isolate Script" = False for your client script

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

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

Sakshi_Singh15_0-1750745051702.png

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 = '2c2d83b3834a22104eea5750ceaad339';//sys_id of MRVS
  if(window == null){//Service Portal
    //hide Add button on MRVS
    this.document.getElementById(mrvsid + '_add_row').style.display = 'none';
    //disable Remove All button on MRVS
    var mrvs = g_form.getField("user_subscription");//internal name of MRVS
    mrvs.max_rows_size = 0;

    //Hide each X (delete row) icon on MRVS
    var icon = this.document.getElementsByClassName("wrapper-xs fa fa-close");
    for(j=0; j<icon.length; j++){
      if(icon[j].getAttribute("title") == 'Remove Row'){
        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('user_subscription'); // Internal name of the MRVS
    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';
    }
  }
}