UI Action Visibility Issue: Hide button in CMDB WS while keeping it visible in Asset WS

MatteoMian0
Giga Contributor

I am facing an issue managing UI Action visibility when a user navigates between different Workspaces (Asset Workspace and CMDB Workspace). I need to find a way to dynamically hide the action based on the active Workspace.

  1. Environment Context
    Table: Configuration Item [cmdb_ci]
    Configuration: Client checkbox selected
    Goal: The UI Action is displayed in the Asset Workspace. Upon clicking, it should open the current record within the CMDB Workspace. Once the record is opened in the CMDB Workspace, the button must disappear to prevent the user from opening the same page repeatedly.

  2. Problem Description
    The UI Action remains visible even in the CMDB Workspace. Consequently, if the user clicks the button again from the new tab, the system opens another identical tab.

  3. Current UI Action Condition
gs.hasRole("sn_cmdb_user") && (RP.getReferringURL() != null && RP.getReferringURL().indexOf('/now/cmdb/') == -1)
  • Script Client Side
function onClick(g_form) {
 var sys_id = g_form.getUniqueValue();
 var table = g_form.getTableName();

 var url = "/now/cmdb/record/" + table + "/" + sys_id;
 top.window.open(url, "_blank");
}​

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@MatteoMian0 

did you try to use action exclusion and try to remove it from CMDB workspace?

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

Aishma Raghu
ServiceNow Employee

You can either:

1. Define a view for the workspace you want the action to show in and include the UI action in that view

2. Create a Form declarative action instead (https://www.servicenow.com/docs/r/platform-user-interface/create-a-new-form-action.html).

By default, a form declarative action will only show up in the experiences/workspaces that it is associated to. You can read more about it in the "Declarative Actions for configurable workspace" section

here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1811593