In servicenow, Ui action, i want that the ui action is visible only to the incident…
- User
In servicenow, Ui action, i want that the ui action is visible only to the incident assigned to person . And not visible to anyone else
- Assistant
In servicenow, Ui action, i want that the ui action is visible only to the incident assigned to person . And not visible to anyone else
In ServiceNow, you can control the visibility of a UI Action based on specific conditions such as the assignee of an incident. You can achieve this using condition scripts in the UI Action. Here's a general approach to make the UI Action visible only to the assigned person of the incident:
Navigate to the desired UI Action: Go to the UI Action you want to conditionally display.
System Definition > UI Actions.Script for condition check: Add a condition script that checks if the current user is the person assigned to the incident. Here's a sample condition script:
// Ensure that current is defined and we're dealing with an Incident
if (current && current.getTableName() === 'incident') {
// Check if the current user is the assigned_to of the incident
gs.getUserID() == current.assigned_to.toString();
} else {
// If not an incident or no current record, do not show the action
false;
}
Condition field: The condition field should contain the logic stated above. In the UI Action form, locate the 'Condition' field and enter the logic:
(current.assigned_to == gs.getUserID())
This will return true if the current user is the assignee of the incident, thus making the UI Action visible to them.
Save and test: Once you have entered the script, save the UI Action and test it by impersonating a user who is assigned to an incident and a user who is not assigned to the same incident. Ensure that the UI Action only shows up for the assigned user.
Example in Detailed Steps:
Navigate to UI Actions:
Open the UI Action:
Add Condition Script:
Enter the following code in the Condition field of the UI Action record form:
(current.assigned_to == gs.getUserID())
Save UI Action:
Save or Update to save the changes.In summary:
The condition script specifically checks if the assigned_to field on the current incident record matches the gs.getUserID() (which gets the ID of the currently logged-in user). This will ensure that the UI Action is only visible to the person assigned to the incident.
If you have advanced requirements or additional roles/conditions, you can extend the script logically to accommodate those conditions.
Not yet included in a published release.