The CreatorCon Call for Content is officially open! Get started here.

Script Required to Show Values of a Choice Field depending on the Value in a Custom Table

Damian Mudge
Tera Expert

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

4 REPLIES 4

Community Alums
Not applicable

Hi @Damian Mudge ,

Kindly provide more details , at the moment your question looks incomplete.

 

HI Sandeep,

 

I have updated the requirement but truly have no idea where to start. Any guidance would be greatly appreciated.

 

Damian

Ankur Bawiskar
Tera Patron
Tera Patron

@Damian Mudge 

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.

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

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