onChange not working as expected for one field type

Shane J
Tera Guru

There is some out of box functionality for Project Management that until today has been driving some of our PMs nuts.   There are two fields that update one anotehr if changed:

 

  • Planned End Date
  • Planned Duration

 

The issue is, if you update Planned Duration and go directly to the 'Update' button and click it - the field updates but the calculation (i.e. the onChange Client Script) doesn't trigger.   It seems like if you do anything else after updating the field, there's no issue.   The client script runs fine (you see the Planned End Date change).

 

Right now I'm thinking of having the Update button do some action of some kind before the 'save' to get around this.   Is that plausible?   What additional scripting in a UI Action would I need to do to send a 'TAB' keystroke or something?

1 ACCEPTED SOLUTION

hheimensen1
Giga Contributor

I think there is difference between a changed database value and a changed value on a form object.



Unlike onLoad() and onSubmit() scripts, onChange() scripts apply to a particular widget on a form rather than to the form itself. They are fired when a particular value changes on-screen.




Because you submit (press the update button) before the object has registered the change it wont't see the change on the form but will register the change.



So I think the script should just be triggered also on submit.


Changing the function of the update button would probably not be the recommended solution.


View solution in original post

5 REPLIES 5

Stephen W_
Giga Guru

That does seem a little strange.   If manually pressing tab causes it to fire, I'm assuming just a change in focus to another control (other than the update button) may suffice.



Something to try: Identify another control by it's ID and use:


$('controlID').focus();


Would controlID just be another field?


Yes, but you may need to right click and "inspect element" to find the ID.


I don't know of a way to get the field's html ID via g_form.


hheimensen1
Giga Contributor

I think there is difference between a changed database value and a changed value on a form object.



Unlike onLoad() and onSubmit() scripts, onChange() scripts apply to a particular widget on a form rather than to the form itself. They are fired when a particular value changes on-screen.




Because you submit (press the update button) before the object has registered the change it wont't see the change on the form but will register the change.



So I think the script should just be triggered also on submit.


Changing the function of the update button would probably not be the recommended solution.