Adding a Custom Button on HR Case Approval Records

Vaniyaa_x
Tera Contributor

Hi All,

Does anyone know how we can add a new custom button to the HR Case Approval record?

Vaniyaa_x_0-1793848939754.png

 

3 REPLIES 3

Sanjay191
Kilo Patron

Hi @Vaniyaa_x 

By creating the declarative action on the target table or UI action that have workspace callable script logic.  

Sanjay191_0-1793866956518.png


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You

 

AndersBGS
Tera Patron

Hi  

 

You can achieve this by creating a declarative form action on the workspace. If you are unfamilar with declarative actions I could recommend https://www.youtube.com/@secretaryofsimplification/videos?view=0&sort=dd&shelf_id=3, https://www.servicenow.com/community/developer-blog/declarative-actions-in-servicenow-the-complete-g...  or the official documentation https://www.servicenow.com/docs/r/platform-user-interface/declarative-actions-landing.html

 

sanjaygupta
Giga Guru

Hi,

Your screenshot shows the approval record (the Approval [sysapproval_approver] table) opened in a workspace. A workspace button is added as a UI action with the workspace options turned on. You need the ui_action_admin or admin role to create it.

  • Go to All > System Definition > UI Actions and click New.
  • Set Table to Approval [sysapproval_approver] and enter the button text in Name.
  • Enter a unique Action name, then select Active.
  • Select Workspace Form Button so the action appears in the workspace button list. Workspace Form Menu puts it in the menu instead.
  • Select Format for Configurable Workspace. The documentation says that if it is cleared, the action applies only in Legacy Workspaces.
  • Add your logic in Workspace Client Script, which runs when the button is clicked in a workspace.
  • Use Condition to control who sees the button, for example only the approver or only certain states.
  • Save, then open an approval in the workspace to check the button. A role set under Requires role limits who sees it.

The workspace may be built on a UI Builder record page, as many HR workspaces are. If the button doesn’t show after the steps above, Community members report that a Declarative Action can be created in Declarative Action Registries (sys_ux_action_registry) for the sysapproval_approver table. They then assign it to the form actions of the approval page. I could not confirm the exact page names for your instance, so check them in UI Builder.

The out-of-box Approve and Reject buttons stay on the form. Community discussions confirm they cannot be hidden by changing their order or names, so keep your button’s purpose distinct from them. Avoid editing the out-of-box UI actions directly. Build the button in an update set or scoped application and test it in a sub-production instance first, since approvals drive case progress.

Sources: