It feels like the data aren’t getting where you think they should be. In update, keep the console log. Only after you see it fire in update, try to run your action and see the result. Remove all code except for the passing of data and logging to check if it’s there.
If that doesn’t work the issue would likely lie in the update code and something blocking those data from passing.
The only real possibility is that the Action is running prior to the Update function, or prior to Update running once the data you are pulling in via Properties is available to it.
You could bring the Properties that you need directly in via the Action, instead of relying on Update? There may be a reason that you are not doing that…
If you have to use Update for some reason then you could do something like:
Set instance.data.init = false In your Initialize function
Within Update Check for values within your Properties object whilst instance.data.init = false
Once you find values then set instance.data.init to true And trigger an event (instance.triggerEvent()) that then, via a workflow, calls your Action.
I often use this kind of switch to better manage how plugins initialise because the sequence of operation during page load is unpredictable and Update will often run several times during one page load.
initialize will always run before update - neither will run when the element is hidden
actions may run before update has had the opportunity to, therefore you can’t rely on update to bring in data that your actions may rely on.
actions won’t run before initialize has run and can therefore reference data and methods that were defined inside initialize, as long as your element is not hidden.
but if it is hidden, actions can still run but you can no longer rely on data or methods that were defined within initialize
So you’re writing your code to reliably work within those constraints - I guess anything that does that can be considered your solution.
Thanks Edward,
You pointed me in the right direction.
The element was shown in the editor, but still the ‘initialize’ function wasn’t triggered because I didn’t mark this option:
“Support standard visible property”
If you don’t enable it, the initialize function never runs.