Script Required to Show Values of a Choice Field depending on the Value in a Custom Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 06:38 AM - edited 12-16-2024 06:55 AM
Within the Incident Management Process and Form, I am trying to pre-populate then Choices in a dropdown box based on the T/F Checkbox Value set in a Custom table.
I am not sure which would be best a Data Policy, UI Policy, Business Rule or Client Script would be most appropriate but I do know I can trigger using the "When to run" Filter options.
This is how I envisage it working but need held with the scripting:
Trigger:
1. When the Incident Category is "Cloud", display the "Category Context" Choices Field. (Successfully accomplished using a UI Policy). However, the values displayed are all the "Choices" as defined when the Choices field was configured. I am trying to return only the values that have a corresponding "True" entry on a separate Custom table.
I need help in defining the "Advanced" script as follows:
IF Logic:
If a corresponding "Category" (incident.category) entry exists in a Custom Table (u_service) for the Customer (incident.u_account) which is a reference to customer_account
AND
API (u_service.u_api) Checkbox is "True", OR AppInfra (u_service.u_appinfra) Checkbox is "True", OR Containers (u_service.u_containers) Checkbox is "True", OR Databases (u_service.u_databases) Checkbox is "True", Storage (u_service.u_storage) Checkbox is "True"
See attached "u_service custom table Input Form.png"
THEN Logic:
Display the "choice" marked as "True" in the "Category Context" displayed Choices.
CONVERSELY IF Logic
If API (u_service.u_api) Checkbox is "False", AppInfra (u_service.u_appinfra) Checkbox is "False", OR Containers (u_service.u_containers) Checkbox is "False", OR Databases (u_service.u_databases) Checkbox is "False", OR Storage (u_service.u_storage) Checkbox is "False"
THEN:
Suppress the "False" value from the "Category Context" displayed Choices.
Where do I start?
Kind regards,
Damian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 06:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 01:46 AM
HI Sandeep,
I have updated the requirement but truly have no idea where to start. Any guidance would be greatly appreciated.
Damian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 07:01 AM
you can use onChange client script + GlideAjax and based on what your script include function returns you can add/remove the choices
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 01:54 AM
Ankur,
Alas, I have limited knowledge of scripting so truly don't know where to start apart form articulating the how the logic should work. Any guidance would be greatly appreciated.
Damian