I’m using a Flex Repeater to display good, rework, and scrap quantities.
Based on the values entered, the system prompts for additional data such as scrap codes and rework codes.
I have on‑change scripts on these three fields, and when multiple work orders are present, the client starts flickering because the on‑change script keeps executing continuously.
Because of this continuous execution, the data bindings are also picking up incorrect values.
I am binding the quantity to the numeric field based on whether it is good, scrap, or rework. For every row script is executing 3 times.
You need to not do it on each field that could change if they need to enter more than one field of info before the refresh.
Give them a button to push to do the refresh on-demand. You could even make it appear when they've got "valid" values in the fields to help enforce appropriate timing.
In addition to Ted's advice, you should also be checking the origin of the event, and ignoring changes that aren't coming from the user (via the browser).
I will refactor it later by introducing a button, but for now I need a workaround.
The change script should execute when the user modifies the field and when the screen loads.
Is there any quick fix for this?
Also, will the ‘origin’ property help in situations where the user enters data from the browser and it is bidirectional, as this is the flex repeater instances.
Unless its triggering off of a timestamp, previousValue.value != currentValue.value will always evaluate to true, which is what is causing your loop.
Yes, User entry will show as 'Browser' origin but bindings will appear as 'Binding' origin. (This is detailed in the link that pturmel posted, take a look.)
For your use case, if origin == 'Browser': is likely enough of a check.
For triggering on page load, have an event script for the onStartup event that calls the exact same code as your message handler to initially load the page.
One more thing — the Flex Repeater is taking too long to load the data. Is there any workaround for this?
All data is available but still showing error