How to hide the Post Incident Review Related list based on Role?

Shaik Sattar
Tera Contributor

Hello Everybody,

 

I want to hide the related list "Post Incident Review" in incident form based on a role "major_incident_manager'.

So only Major Incident Managers can only see the tab in both UI and in the Service Operations Workspace.

 

I can't see the Related list name to write a OnLoad Client Script with the sys_id, can someone help me on this?

UI Backend:

ShaikSattar_0-1767086412695.png

Workspace:

ShaikSattar_1-1767086541395.png

This is OOTB behavior but we want to customize it so that only Major Incident Managers can see those tabs in both UI and workspace? please help me on this

Thanks in Advance!

 

@Ankur Bawiskar 

Thanks,

Sattar

11 REPLIES 11

@Shaik Sattar 

did you debug the client script by adding alert?

if it's going inside that IF then it means it should hide unless the related list name is wrong

function onLoad() {
    if (!g_user.hasRole('major_incident_manager')) {
		alert('now hiding related list');
        g_form.hideRelatedList('sn_sow_inc_post_incident_review.incident_ref');
    }
}

 

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

@sattar3 

Thank you for marking my response as helpful.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Ankur Bawiskar
Tera Patron

@Shaik Sattar 

To make it work for workspace there is a long path involving UI builder and duplicating the Record page variant

I will suggest to avoid this much customization due to technical debt and maintenance.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Dhanraj B
Giga Guru

Hi @Shaik Sattar ,

 

You are doing it right but a small change. Use something like below.

function onLoad() {
    if (!g_user.hasRole('major_incident_manager')) {
        g_form.hideRelatedList('sn_sow_inc_post_incident_review.incident_ref');
    }
}

This script will hide the related list, if the users don't have the role "major_incident_manager".

 

-Dhanraj.

sattar3
Tera Contributor

@Ankur Bawiskar , @Dhanraj B thank you