Need to hide "Add / Edit / Remove" buttons from Approvers related list in SC Task

FemyM
Tera Contributor

I have a requirement to hide the Add, Edit, and Remove buttons from the Approvers related list (sysapproval_approver) on an SC Task after a particular task is closed complete.

 

I created a Client Script (onLoad) on the sc_task table using:

 

 
g_form.setRelatedListShowAdd('sysapproval_approver', false); g_form.setRelatedListShowActions('sysapproval_approver', false);

But the buttons are not hiding.

I also tried placing the script inside a UI Policy with no success.

Is there a reliable way to hide the Add / Edit / Remove related list buttons for the Approvers list?

4 REPLIES 4

TariqueWasim
Tera Contributor

You can do it through List Control to Omit New/Edit Button

OlaN
Tera Sage
Tera Sage

Hi,

The buttons are there as long as you have access to create/modify/delete records in that table.

You can hide the related list altogether with an UI policy and UI policy related list action if that's what you're after.

 

Otherwise you'll need to configure the list control of the related list, and omit the buttons (and probably set a condition for when the button should be omitted.

 

configure-list-control.png

FemyM
Tera Contributor

Hi, 
I found the buttons in Related list actions.

But 

I am working on a custom Edit button for the sysapproval_approver table . The requirement is:

  • Block editing if the approval state is requested, approved, or rejected.

  • Allow editing only if the state is 'not yet requested'.

  • Show an error message when editing is blocked.

I tried the following approaches:

  1. Server-side UI Action using current.setAbortAction(true) and gs.addErrorMessage() — works perfectly for a Remove button, but for Edit, the M2M edit page does not open correctly.

  2. Client-side GlideAjax / Script Include — logic works, but asynchronous calls and scope issues prevent reliable M2M page opening.



    I want a solution where the Edit button:

    • Blocks editing for processed approvals

    • Opens the M2M edit page when allowed

    • Works reliably on forms, related lists, and M2M templates

Ankur Bawiskar
Tera Patron
Tera Patron

@FemyM 

script you shared won't work in workspace

OOTB I couldn't find New, Add, Edit button on Approvers Related list on sc task form

seems somebody added that with some custom solution

AnkurBawiskar_0-1764838306529.png

 

💡 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