I want to restrict the accessibility of Re-Assess button for ITIL Users on a problem task.

Raahul2
Tera Contributor

The Re-Assess button is an OOB UI Action on the PTask. I want to restrict the access and visibility for ITIL users. Tried the condition in the UI action but did not work. I am trying to have the access only for the Assigned group members and assigned group manager. No ITIL user should have access to the button,

Condition used :

new ProblemTaskStateUtils().isAllowedToReAssess(current) && current.state == 154 || current.state == 157 && (gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) && !gs.getUser().hasRole('itil')

 

 

1 ACCEPTED SOLUTION

Viraj Hudlikar
Tera Sage

Hello @Raahul2 

 

It looks like there might be an issue with the logical operators and the grouping of conditions. Here's a revised version of your condition:

 

(new ProblemTaskStateUtils().isAllowedToReAssess(current) && 
(current.state == 154 || current.state == 157) && 
(gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) && 
!gs.getUser().hasRole('itil'))

 

By grouping the conditions with parentheses, you ensure that the logic is evaluated correctly. Apply this condition to the UI Action and test it to see if it works as expected.

 

If you still encounter issues, you might want to add some logging to debug the condition. For example:

 

gs.log("User: " + gs.getUserID() + ", isMemberOf: " + gs.getUser().isMemberOf(current.assignment_group) + ", isManager: " + (gs.getUserID() == current.assignment_group.manager) + ", hasRole: " + gs.getUser().hasRole('itil'));

 

This will help you understand which part of the condition might be failing.

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

10 REPLIES 10

Viraj Hudlikar
Tera Sage

Hello @Raahul2 

 

It looks like there might be an issue with the logical operators and the grouping of conditions. Here's a revised version of your condition:

 

(new ProblemTaskStateUtils().isAllowedToReAssess(current) && 
(current.state == 154 || current.state == 157) && 
(gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) && 
!gs.getUser().hasRole('itil'))

 

By grouping the conditions with parentheses, you ensure that the logic is evaluated correctly. Apply this condition to the UI Action and test it to see if it works as expected.

 

If you still encounter issues, you might want to add some logging to debug the condition. For example:

 

gs.log("User: " + gs.getUserID() + ", isMemberOf: " + gs.getUser().isMemberOf(current.assignment_group) + ", isManager: " + (gs.getUserID() == current.assignment_group.manager) + ", hasRole: " + gs.getUser().hasRole('itil'));

 

This will help you understand which part of the condition might be failing.

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Hi Viraj,

Thank you for the reply. i have tried this script but now, the UI action is not visible for admins.

 

( new ProblemTaskStateUtils().isAllowedToReAssess(current) && (current.state == 154 || current.state == 157) && (gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) || gs.getUser().hasRole('admin') &&
!gs.getUser().hasRole('itil'))

Ankur Bawiskar
Tera Patron
Tera Patron

@Raahul2 

try this

 

new ProblemTaskStateUtils().isAllowedToReAssess(current) && 
(current.state == 154 || current.state == 157) && 
(gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) && 
!gs.hasRole('itil')

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur,

Thank you for the reply. i have tried this script but now, the UI action is not visible for admins.

 

( new ProblemTaskStateUtils().isAllowedToReAssess(current) && (current.state == 154 || current.state == 157) && (gs.getUser().isMemberOf(current.assignment_group) || gs.getUserID() == current.assignment_group.manager) || gs.getUser().hasRole('admin') &&
!gs.getUser().hasRole('itil'))