- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 01:40 AM
I have a below requirement and how to achieve this through ACL?
WHEN I open the Scrum Task and enter the Planned hours in the field
THEN I see the below validation:
if the current date-time is between Story.Sprint.Planned start date and Story.Sprint.Planned end date on scrum task, AND Story.Assignment Group is “ITSM group” or “CMDB group” or “Platform group” or “Major incident group”
then the “Planned hours” field should be editable only to members of the group “Scrum Admins”
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 01:54 AM
Hi @shaik riyaz1 ,
This can be achieved by using a field level write ACL.
Select the appropriate table(scrum task) and field (planned hours)
In the advance section of the script try the below code-
// Check if user is in Scrum Admins group
if (!gs.hasRole('scrum_admins')) {
return false; // User is not in the required group
}
// Get the current date
var currentDate = new GlideDateTime();
// Retrieve the related story's sprint information
var story = new GlideRecord('rm_story'); // Assuming 'rm_story' is the table for stories
if (story.get(current.story)) {
var sprint = new GlideRecord('rm_sprint'); // Assuming 'rm_sprint' is the table for sprints
if (sprint.get(story.sprint)) {
var plannedStartDate = sprint.planned_start_date;
var plannedEndDate = sprint.planned_end_date;
// Check if the current date is between the sprint start and end dates
if (currentDate >= plannedStartDate && currentDate <= plannedEndDate) {
// Check if the story's assignment group is one of the specified groups
var assignmentGroup = story.assignment_group.getDisplayValue();
if (['ITSM group', 'CMDB group', 'Platform group', 'Major incident group'].indexOf(assignmentGroup) > -1) {
return true; // Allow access to the field
}
}
}
}
// Deny access if conditions are not met
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 01:54 AM
Hi @shaik riyaz1 ,
This can be achieved by using a field level write ACL.
Select the appropriate table(scrum task) and field (planned hours)
In the advance section of the script try the below code-
// Check if user is in Scrum Admins group
if (!gs.hasRole('scrum_admins')) {
return false; // User is not in the required group
}
// Get the current date
var currentDate = new GlideDateTime();
// Retrieve the related story's sprint information
var story = new GlideRecord('rm_story'); // Assuming 'rm_story' is the table for stories
if (story.get(current.story)) {
var sprint = new GlideRecord('rm_sprint'); // Assuming 'rm_sprint' is the table for sprints
if (sprint.get(story.sprint)) {
var plannedStartDate = sprint.planned_start_date;
var plannedEndDate = sprint.planned_end_date;
// Check if the current date is between the sprint start and end dates
if (currentDate >= plannedStartDate && currentDate <= plannedEndDate) {
// Check if the story's assignment group is one of the specified groups
var assignmentGroup = story.assignment_group.getDisplayValue();
if (['ITSM group', 'CMDB group', 'Platform group', 'Major incident group'].indexOf(assignmentGroup) > -1) {
return true; // Allow access to the field
}
}
}
}
// Deny access if conditions are not met
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 03:52 AM
Hi @shaik riyaz1 ,
Based on the response form our colleagues , you can also add the groups under data condition , that way you need not worry about name change of groups in future.
Please mark helpful/correct if my response helped you.