Hide Preview icon on related list

Naga Ravindra R
Kilo Sage

I want to hide preview option in the related list. Something like below in scoped application table.

 

NagaRavindraR_0-1715770788169.png

 

I tried some UI scripts in the community, didn't find the exact solution. Any help would be appreciated.

Thank you

 

11 REPLIES 11

Hi @Stefan Lowrie 

Please observe the solution here in this post.

 

Thanks,

Narsing

Narsing1
Mega Sage

Hi,

Please go through with this article

All about Preview Icon 

 

Thanks,

Narsing

Narsing1
Mega Sage

Hi, 

Found the solution for it.  

Step #1 (To find the ID of the table)

Right click on the Preview Icon ==> Inspect like this

Screenshot 2024-08-04 081504.png

In this case, I would like to Hide the Task SLA Related List Preview icon.  So just took the HTML Table ID of it and my id is "incident.task_sla.task_table".

Screenshot 2024-08-04 081920.png

Now, create a UI Script like this 

Note: Cell[1] will be always a preview Icon.  So you can have a hardcoded one.

Screenshot 2024-08-04 082107.png

(function() {
    addAfterPageLoadedEvent(function() {
        if ((window.location.href.indexOf('incident') != -1)) {
            var table = document.getElementById("incident.task_sla.task_table");
            for (var i = 0; i < table.rows.length; i++) {
                table.rows[i].cells[1].style.display = "none";
            }
        }
    });
})();

You are done and the final result is like this

Before#

Screenshot 2024-08-04 082255.png

After#

Screenshot 2024-08-04 082411.png

 

Thanks,

Narsing

 

Reposting this reply.  So I added a different related list to the form.  The URL for the record I'm viewing that has the related list is as follows plus params for sysId etc added:

/now/nav/ui/classic/params/target/cmdb_ci_service.do

 

Now when I inspect the preview icon (screenshot below) on a row in that related list, the table id = cmdb_ci_service.kb_knowledge.cmdb_ci_table

 

So I used your script replacing incident with cmdb_ci_service and  incident.task_sla.task_table with cmdb_ci_service.kb_knowledge.cmdb_ci_table.  Here's the script:

 

(function() {
    addAfterPageLoadedEvent(function() {
        if ((window.location.href.indexOf('cmdb_ci_service') != -1)) {
            var table = document.getElementById("cmdb_ci_service.kb_knowledge.cmdb_ci_table");
            for (var i = 0; i < table.rows.length; i++) {
                table.rows[i].cells[1].style.display = "none";
            }
        }
    });
})();
 
Any idea what I'm missing here?  The preview icon persists.  Thank you!

 

StefanLowrie_0-1723157309469.png