How to hide edit row option in a multirow variable set for specific catalog in RITM level

Sowmya
Tera Contributor

Hi Team,

I was able to create UI poilicy and set it ready only for entire variable but i want to hide the edit row icon itself for that particular catalog in RITM level. have used the below client script but still not working Can anyone suggest where i am going wrong.

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

function disableButtons() {
    var my_var = g_form.getField("vm_details_dev");//use your variable set name here
    var icon = this.document.getElementsByClassName("wrapper-xs fa fa-pencil");
    for (i = 0; i < icon.length; i++) {
        if(icon[i].getAttribute("title") == 'Edit Row') {
            icon[i].style.display='None';
        }
    }  
    //To hide Edit icon, then use the class name as fa-pencil instead of fa-close
}
3 REPLIES 3

Community Alums
Not applicable

Hi @Sowmya ,
Try this script-

function onLoad() {
// Delay execution to ensure that all elements are loaded
setTimeout(function() {
disableEditRowIcon();
}, 2000);
}

function disableEditRowIcon() {
var fieldName = "vm_details_dev"; // Update with the correct field name
var field = g_form.getField(fieldName);

if (!field)
return; // Field not found, exit function

 

var icons = document.querySelectorAll('.wrapper-xs.fa.fa-pencil');

for (var i = 0; i < icons.length; i++) {
var icon = icons[i];
if (icon.getAttribute("title") == 'Edit Row') {
icon.style.display = 'none'; // Hide the icon
}
}
}


Mark my Answer Helpful or Accept Solution if it resolves your issue.

Sowmya
Tera Contributor

@Ankur Bawiskar :Could you please help on this

Ankur Bawiskar
Tera Patron
Tera Patron

@Sowmya 

this uses DOM manipulation.

Ensure Isolate Script is set as False for your client script for DOM to run

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