Hide Add/ Remove All , 'X' , Edit Row icon in MRVS on Service Portal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 10:35 PM
If you have Multiple MRVS on your Catalog item , and you are populating the value and want to hide the Buttons and icon , you can follow this catalog client script code and edit according to your needs.
function onLoad() {
//Type appropriate comment here, and begin script below
var hide_removeall = true;
var hide_add = true;
var hide_deleterow = true;
var hide_editrow = true;
// List of MRVS to process
var mrvsList = [
{ name: 'user_subscription', id: '2c2d83b3834a22104eea5750ceaad339' },// Internal name of MRVS and sys_id
{ name: 'software_installation', id: 'f0fe4f73834a22104eea5750ceaad3ea' }
];
// Loop over all MRVS entries
for (var m = 0; m < mrvsList.length; m++) {
var mrvsname = mrvsList[m].name;
var mrvsid = mrvsList[m].id;
// For Service Portal
if (window === null) {
var sheets = this.document.styleSheets;
var sheet = sheets[0];
var rule_params = [];
if (hide_removeall) { rule_params.push('#' + mrvsname + ' .btn-default'); }
if (hide_add) { rule_params.push('#' + mrvsname + ' .btn-primary'); }
if (hide_deleterow) { rule_params.push('#' + mrvsname + ' .fa-close'); }
// if (hide_editrow) { rule_params.push('#' + mrvsname + ' .fa-pencil'); }
sheet.insertRule(rule_params.toString() + ' { display: none !important; }');
} else {
// Native UI
if (hide_removeall) {
var removeAllBtn = g_form.getElement(mrvsid + 'removeAllRows');
if (removeAllBtn) removeAllBtn.hide();
}
if (hide_add) {
var addBtn = g_form.getElement(mrvsid + 'Add');
if (addBtn) addBtn.hide();
}
if (hide_deleterow || hide_editrow) {
var addBtnEl = g_form.getElement(mrvsid + 'Add');
if (addBtnEl) {
var rows = addBtnEl.getOffsetParent().getElementsByClassName('sc-multi-row-actions');
for (var i_row = 0; i_row < rows.length; i_row++) {
var icons = rows[i_row].getElementsByClassName('btn');
if (hide_editrow && icons[0]) icons[0].hide();
if (hide_deleterow && icons[1]) icons[1].hide();
}
}
}
}
}
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 11:00 PM
so is this a question or an informative article?
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
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader