Need to restrict the close of catalog task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 03:40 AM
Hi All,
Query
1) Only the ITIL user who is part of the assignment group can close the catalog Task. (Admins are allowed)
2) Persons who are not part of groups are restricted to close the catalog task.
3) Requester who has raised the request are allowed to close the catalog task
Please any one provide me the input,
Thanks in advance,
Vinuth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 08:51 AM
UI action condition I shared should work fine.
Did you debug that UI action condition?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 05:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 06:01 AM
few changes
1) you didn't select the form button or any other checkbox then how that UI action will be shown
2) also are you sure u_requested_by field is populated with the user sysId
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Step 1: Create a Business Rule
- Navigate to System Definition > Business Rules.
- Click New.
- Fill in the form:
- Name: A descriptive name like "Restrict Task Closure to Assignment Group".
- Table: Select the task table you need to restrict (e.g., sc_task, incident, problem_task).
- Active: Ensure this is checked.
- Advanced: Click the "Advanced" tab and check the Advanced box.
Step 2: Set the condition
- Under the When to run tab, set the following:
- When: before.
- Operation: update.
- Condition: While the "advanced" tab is used for the script, you can add the condition here as a first check, although the script will perform the primary validation. For example, Assignment group is not empty.
Step 3: Add the script
- In the Advanced tab, add the following script to the Script field. This script checks if the current user is a member of the task's assignment group. If not, it adds an error message and prevents the update (closure) from happening.
JavaScript
(function executeRule(current, previous /*null when async*/) {
// Check if the user is a member of the task's assignment group
if (!gs.getUser().isMemberOf(current.getValue('assignment_group'))) {
gs.addErrorMessage("You cannot close this task because you are not a member of the assignment group.");
current.setAbortAction(true);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Step 1: Create a Business Rule
- Navigate to System Definition > Business Rules.
- Click New.
- Fill in the form:
- Name: A descriptive name like "Restrict Task Closure to Assignment Group".
- Table: Select the task table you need to restrict (e.g., sc_task, incident, problem_task).
- Active: Ensure this is checked.
- Advanced: Click the "Advanced" tab and check the Advanced box.
Step 2: Set the condition
- Under the When to run tab, set the following:
- When: before.
- Operation: update.
- Condition: While the "advanced" tab is used for the script, you can add the condition here as a first check, although the script will perform the primary validation. For example, Assignment group is not empty.
Step 3: Add the script
- In the Advanced tab, add the following script to the Script field. This script checks if the current user is a member of the task's assignment group. If not, it adds an error message and prevents the update (closure) from happening.
JavaScript
(function executeRule(current, previous /*null when async*/) {
// Check if the user is a member of the task's assignment group
if (!gs.getUser().isMemberOf(current.getValue('assignment_group'))) {
gs.addErrorMessage("You cannot close this task because you are not a member of the assignment group.");
current.setAbortAction(true);
}
})(current, previous);
