- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:12 AM - edited 04-30-2024 01:15 AM
Use Case:
I have a UI Action and I want to hide/show it based on a field form value.
OR
How to rename UI Action in client script?
How to do this?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:34 AM
Hi @ican,
Best practice and the easiest way would be to leverage the UI Action 'Condition' field.
A simple example and syntax would be as follows:
current.state == 3 // where the state field value is equal to 3. You can add additional conditions by simply using ''&&' current.fieldname etc
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:15 AM
Try this @ican
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:19 AM - edited 04-30-2024 01:27 AM
- Create a UI Policy --> Set the Condition in the When to Apply section for your field.
- In the Script tab set Run scripts true.
3. In the Execute if true section, write. $$('#action_name')[0].hide(); //This will hide the button. ..
4. In the Execute if false section write. $$('#action_name')[0].show(); //This will show the button.
the action_name is the action_name of the ui_action you want to hide. If it is blank set it to a value of your choice
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:26 AM
I tried this and im having this error: $$ is not a function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:28 AM
Hi,
To show / Hide UI Action, why dont you add the logic in the ui action's condition?