JavaScript API interaction with server side validation...

I have a field A, which I am trying to detect a change in on the client and then pass a flag to the server in field Z.
I am using AddChangeCallback to set field Z when A changes.
On the server I am able to query field Z to know that A has changed during the transition.

However, I have a field Q which is a required field.
If I change field A and leave field Q blank then the server side validation fails and this causes the page to reload.
When the page is reloaded field A still contains the new value, but I no longer know that this has changed.

Is there a better way to reliably detect changes in the client? At present I am checking whether an error is displayed on page load and if so then I have to assume everything has changed which is not ideal for me. I have submitted another post recently about this... I am trying to call a web service method on the server, but this is an expensive operation and I would only like to do this when a field is actually changed.

Any help or thoughts about this would be much appreciated... thanks!!
Parents Reply Children
  • I am clearing the field on form load, which is the cause of the problem. I am wondering whether to clear the field on the server instead... possibly in a pre-transition step or set the field to a default value for each transition, and/or possibly reset the field on the post-transition step once I have processed my on change handling on the server.
  • I am not sure whether you can fire orchestrations from notifications, it has not been something I have actually looked into... do you know if this is possible? However, what I am trying to achieve is complex server side validation using a web service method, so the idea was to use a synchronous orchestration on my transition, so that I can then throw an error and prevent the transition from occurring. I am not sure whether you would be able to achieve the same thing and prevent a transition using notifications... I would expect not, but again this is not something I have looked into.
  • On the transitions that are using the form, you can override the field and choose to Clear the field. This will occur before the form comes into play and the field would not be cleared again because of a missing required field.

    You can fire an orchestration from a notification, but it would be an asynchronous orchestration.
  • Thanks Lynn, after much mulling over and trying things out I ended up going down your route of overriding the field on the transitions that use the form. This works as you have suggested and the field is only cleared once. Thanks very much for your help with this!