- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 02:27 AM
my Requirement is to disable the pencil icon i.e Edit icon in a multi-row variable set for a certain record?
Any solution would be welcome.
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 04:47 AM
Hello Arushi,
Good to know that my articled helped you. If you want to hide for specific icon, there is no directly way.
In your rows , you can do a check for the text in the 1st column (after pencil) and if that matches you can hide it. Here is sample code for that.
icon = this.document.getElementsByClassName("wrapper-xs fa fa-pencil");
for (i = 0; i < icon.length; i++) {
if (icon[i].getAttribute("title") == 'Edit Row') {
if (icon[i].parentNode.nextElementSibling.innerText == 'YOUR TEXT') {
icon[i].style.display = 'None';
}
}
}
In the code, replace it with your text and then check. Then it will disable the pencil icon only for that row having that text.
Mark the comment as a correct answer and helpful once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 03:48 AM
Hi
yes, I want that if I have 5 rows then I want to remove it for a particular row like for 2nd row the edit icon should be disabled not for all rows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 04:00 AM
Hi,
will it be always for 2nd row?
what happens if there is only 1 row
for your example if you have 5 rows and want to hide it only for 2nd row then use this script
- Ensure Isolate Script field is set to false
- This field is not on form but from list you can make it to false
If you want to hide it on RITM then use Applies on Requested Item - True
If you want to hide it on SC Task then use Applies on Catalog Task - True
function onLoad() {
//Type appropriate comment here, and begin script below
var z = this.document.getElementsByClassName("btn icon-edit btn-sm");
// index starts from 0
// so z[1] means 2nd row
z[1].style.display = 'none';
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 04:22 AM
Hi sir,
The row can b different it can b two or more rows also.
I'm getting an error when I run code as There is a JavaScript error in your browser console why it's coming so?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 04:47 AM
Hello Arushi,
Good to know that my articled helped you. If you want to hide for specific icon, there is no directly way.
In your rows , you can do a check for the text in the 1st column (after pencil) and if that matches you can hide it. Here is sample code for that.
icon = this.document.getElementsByClassName("wrapper-xs fa fa-pencil");
for (i = 0; i < icon.length; i++) {
if (icon[i].getAttribute("title") == 'Edit Row') {
if (icon[i].parentNode.nextElementSibling.innerText == 'YOUR TEXT') {
icon[i].style.display = 'None';
}
}
}
In the code, replace it with your text and then check. Then it will disable the pencil icon only for that row having that text.
Mark the comment as a correct answer and helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 04:52 AM
If the value to check is not in the 1st but in 2nd column after pencil, then you can check like this. Same logic whichever column it is.
use nextelementSibling to go to that element and use innerText to get the value.
icon = this.document.getElementsByClassName("wrapper-xs fa fa-pencil");
for (i = 0; i < icon.length; i++) {
if (icon[i].getAttribute("title") == 'Edit Row') {
//this gives you 1st element
var elm = icon[i].parentNode.nextElementSibling;
//below nextElementSibling again to elmwill you 2nd column text after edit icon.
if (elm.nextElementSibling.innerText == 'Field one 1') {
icon[i].style.display = 'None';
}
}
}