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 07:29 AM
Hey Ralph,
I think you will have to write 2 ui policies to achieve this. One for each field.My suggestion is to avoid coding where ever possible as it loads the system.
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 08:35 AM
I'm going back to the original policy I created. I had it working almost the way I wanted.
The fields show/hide the way I want the first time I enter the form.
I can change Incident States and it behaves perfectly.
Here's my problem
I Update the form when it is in the Dispatched Tech state and the two fields are visible. Perfect.
The problem I am having is that the two fields are hidden the next time I open the form even though the Dispatched Tech state is true.
Here's what my Policy looks like

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 09:55 AM
Looks like you renamed State to Incident State, which is fine. The next time you open the form - the conditions must be false. Can you confirm that both Incident States have the correct choice?
If they do, you might try using the Add OR clause. That might cover you better. Next to the word Conditions, there is add filter condition and add or clause. I'm referring to add or clause.
So instead of
incident state is x or incident state is x
try:
Incident state is x
OR
Incident state is x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2017 09:57 AM
You were right. I had to create 2 policies. One to hide the fields and the other to show the fields. Works perfectly now.
Thanks.