We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Need to hide declarative action assignment button in workspace

Shubham Bongulw
Giga Guru

Hi Community,

I have requirement in which I want to make buttons visible in change request form in workspace only when user logged belong to assignment group or he has change manager role.

I can manage the code if it was UI action but not sure how Declarative action code works or how can I add condition to hide it. I have configured it as below- 

ShubhamBongulw_0-1744110506330.png

currently cancel button is visible for all user in action dropdown in workspace. Can someone please help me how to achieve this?

8 REPLIES 8

Dr Atul G- LNG
Tera Patron

Hi @Shubham Bongulw 

 

Sightly helpful :

 

https://www.servicenow.com/community/now-platform-forum/how-to-hide-ui-action-button-conditionally-o...

 

https://www.servicenow.com/docs/bundle/vancouver-platform-user-interface/page/administer/workspace/t...

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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

Hi,

I already have gone through this documentation but it didn't helped at all.

Ankur Bawiskar
Tera Patron

@Shubham Bongulw 

the OOTB "Cancel change request" form declarative action has condition in "Script condition" field

Simply add this to your existing Script Condition field

Existing Condition && gs.hasRole('change_manager') && gs.getUser().isMemberOf(current.assignment_group)

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

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

Hey Ankur,

tried this as well but it's getting hidden from current assignment group user 

. Here is the complete code- gs.hasRole('itil,sn_change_write') && new global.ChangeFormUI(current).isCancelAvailable() && gs.hasRole('change_manager') && gs.getUser().isMemberOf(current.assignment_group)