Conditionally Hide and Display fields on Incident state using OnChange
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 07:18 AM
I need to conditionally Display and Hide two fields when Incident state changes to and from Dispatched Tech.
I tried this with a UI Policy but it seems I need more than just the On Load event.
I am wondering if the following is a good starting point for an OnChange() script. I am not a javascript programmer but can usually adapt others code to do what I need.
Incident state choice
Dispatched Tech which has a value of -3
The two fields I need to Hide and Display OnChange
u_tech_eta
u_tech_confirmation_number
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue != 'Dispatched Tech'){
g_form.setDisplay('u_tech_eta', false); // Tech ETA
g_form.setDisplay('u_tech_confirmation_number', false); // Tech Confirmation Number
}
}
Ralph Alberti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 02:43 PM
I was able to duplicate what you did in my dev instance, but switched Visible to True, and it behaved exactly as intended.
When I tried it with my fields and policies, it didn't work. I have another policy that is using those same fields and I believe I have a conflict occurring.
I've got to leave it be for now and stick with the 2 policies that are proven to work correctly.
But I agree, I should be able to do it with one policy and will revisit sometime in the future.
Just have to slow down and take it one step at a time to figure out what is going on.
Thanks for the suggestions though. They were helpful.
--Ralph
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 04:12 PM
For the future. If you multiple UI policies on the same field, try to merge them into 1. Most time that is possible with some more complex conditions. Otherwise order is your friend there.
Just let me know when you want some help.