Hide Choices on contact_type field on HR Case based on Assignment group values.

ImpuV
Tera Contributor

Hi Everyone,

 

I have a requirement where Assignment group is ABC or XYZ I need to hide 3 choices under Source (contact_type) field which is a reference field. 

Hide only 2 choices and set a default value when assignment group is AAA or CCC - Need to do this for a couple of groups.

I have tried using removeOption on OnLoad script but realised it doesn't work on Reference fields. 

How do I achieve this?

6 REPLIES 6

Kristen Dettman
Kilo Sage
Kilo Sage

I believe you could add an advanced reference qualifier to your Source field, then point to a script include where you have your condition logic. Here is an example of what I'm thinking:

 

https://www.servicenow.com/community/developer-forum/add-a-reference-filter-to-field-based-on-a-cond...

 

Have a great day!

Kristen

Gangadhar Ravi
Giga Sage
Giga Sage

if it is reference field the you need to implement reference qualifier.   Please check below to find how advanced reference qualifiers work. 

https://servicenowguru.com/script-includes-scripting_advanced-reference-qualifier-script-include/

swathisarang98
Giga Sage
Giga Sage

Hi @ImpuV ,

 

I have a requirement where Assignment group is ABC or XYZ I need to hide 3 choices under Source (contact_type) field which is a reference field.  - > [you can create a script include and a reference qualifier to filter out the choices from reference field - Swathi] 

 

Hide only 2 choices and set a default value when assignment group is AAA or CCC - Need to do this for a couple of groups. -> [In the same script include you can mention this point - Swathi ]

 

I have tried using removeOption on OnLoad script but realised it doesn't work on Reference fields. 

How do I achieve this? -> [In the same script include create one more function and return the value and call this second function in Default value of assignment group this should auto populate the value -Swathi]

 

Let me know if you need help with the scripting , and please do share whatever you have tried so far with some screen shots.

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

Hi Swati,

Thank your help. 

I am trying to hide choices on this field and Set default value 

For eg : Assignment group is AAA/ BBCv - Show 3 choices and set 'Phone' as Default value.

Assignment group is ABC - Show 5 choices and set 'Other' as default value.

28 assignment groups for which I need to show 3 choices and set 'Email' as default  value.

ImpuV_0-1716278559391.png

based on the Assignment group. This is the Dictionary entry of the field. I have tried to hide options for the same field on INC form using addOption/removeOption. But it's not working for HR Case form.

 

ImpuV_1-1716278678204.png

I mistook this to be a Reference field. Apologies.