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

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Shaik Sattar 

For native you can show/hide section using onLoad client script using g_form.hideRelatedList()

For native

  • Go to any form where the related list is present.
  • Right-click to open the column context menu on the related list.
  • Select Configure > List control.
  • the ‘Related list’ field value from the list control. (Suppose - "Related_list_value" is the value)
  • g_form.showRelatedList('Related_list_value');

The above won't work for workspace as that function is not supported

function onLoad() {
    if (!g_user.hasRole('major_incident_manager')) {
        g_form.showRelatedList('Related_list_value');
    }
}

💡 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

Hi @Ankur Bawiskar thanks for your reply.

 

All the Incident Post Reviews are stored in "sn_sow_inc_post_incident_review.incident_ref" table.

I tried the same as you mentioned, there is no existing List control available.

I created it but it didn't work, please check the below screenshots and correct me if anything is wrong?

ShaikSattar_0-1767091000548.png

List Control- Related List Name: sn_sow_inc_post_incident_review.incident_ref

ShaikSattar_1-1767091068168.png

Client Script:

ShaikSattar_2-1767091175875.png

 

Thanks,

Sattar

 

 

@Shaik Sattar 

you are using wrong script

You should hide it when role is not your role

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

💡 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 it is also not working.

I impersonated a user who don't have major incident role but he can see the related list.

ShaikSattar_0-1767092165978.png

 

Thanks,

Sattar