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 10:39 AM
I dont get why you would need 2 UI policies for this.
First, no need to have it both on incident state and state since OOB there are functionality behind that makes sure these have the same value.
Before I type more.. you say you want to hide the field when it changes. But if you load a form that is in state "dispatched tech" should they also be hidden?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 10:51 AM
Looking at you example above. Just remember the incident_state condition and keep the state.. then if you only want it to hit when the user changes the value, uncheck the "onLoad" field. Otherwise it will show/hide depending on if the state is "dispatched tech" or not when the form loads without user changing any value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 11:03 AM
Good point on the Incident State and State issue. I was just being overly cautious.
Here's a screenshot of my form. The problem I was having was as follows;
- The two fields would hide ok On Load because I had the Reverse if false checked
- The two fields would become visible ok when I selected the Dispatched Tech incident state
- But.... our agents don't necessarily have the information to complete those fields at the time they Dispatch a Tech so they would hit Update and come back to it later.
- When reopening the form, the two conditional fields would not Display even though the Incident State was Dispatched Tech. No matter what I tried, I couldn't get those two conditional fields to become visible again. In my mind, they should be visible because the Dispatched Tech state was active.
So now I have two Policies where I basically reverse the Conditions and Visible UI Actions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 11:50 AM
I'm with goranlundqvist, you shouldn't need 2 UI policies to achieve this.
Looking at your conditions again, I still think that's where the problem exists. 2 different fields separated by an order, if the first one is false, it's not checking the 2nd part of the OR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 12:03 PM
It should work. What you are doing is about the most basic UI Policy you can do.
One thing to remember is that for it to evaluate the field needs to be on the form(hidden or showing). Otherwise it can do the condition.. I think the incident_state might e the issue here..
I did this quick and this one hits when the user changes to "in progress" or loads a record which already has it set to "in progress".
I would recommend deleting the existing ones and redoing it from scratch (have been experience (not often) UI Policies that is corrupt and needs to be redone from scratch.
Not good to have 2 ui polices running when you can solve it by 1(performance wise)