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

@Raahul2 

are you sure admin user satisfies all the conditions

Remember admin will inherit itil role so it won't work for admins

use this to allow for admins

gs.hasRole('admin') || (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'))

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Raahul2 

 

Please check this OOTB property before you make any changes

 

AGLearnNGrow_0-1739958135724.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atul,

Thanks for the reply. However, I do not find these properties. Could you please guide me.

 

Regards,

Hi @Raahul2 

 

These are available under problem management

AGLearnNGrow_0-1739960240953.png

 

https://INSTANCENAME.service-now.com/now/nav/ui/classic/params/target/system_properties_ui.do%3Fsysparm_title%3DProblem%2520Management%2520Properties%26sysparm_category%3DProblem%2520State%2520Transition%2520Properties%2C%2520Problem%2520Task%2520State%2520Transition%2520Properties%2C%2520Problem%2520Related%2520List%2520Properties%2CKnowledge%2520Related%2520Properties%2C%2520Problem%2520Created%2520from%2520Incident%2520Properties%2C%2520Problem%2520from%2520Interaction%2520Properties

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atul,

Thanks for the reply. I have checked that. By default it has only problem coordinator role. I cannot add any other role to it.