Good evening all, I'm hoping someone has run into this issue and has a solution. I have a block with a structure as an input parameter. The structure contains 3 elements that often change at the same time in the parent screen. I'm seeing that when this occurs my OnParametersChanged event fires 3 times but I really only need it to be handled once for the change.
I tried adding a counter into my onParametersChanged defaulted to 0 and then using an If statement to end the action if the value is 1 but unfortunately that did not work because I was only capturing the first structure element that had changed. Then I tried using the same logic but only finishing the action when the value was 2 (all 3 elements had changed) and that did work.... but it failed in scenarios where only 2 of the 3 structure elements had changed.
Any suggestions? I wish there was a way to see which element the OnChange event was firing for and then I could use that to determine what action I need to take, but I can't figure out how to determine that.
Hello Josh,
The easiest workaround would be to serialize/deserialize multiple inputs into one input parameter.
To do that follow the following refactoring steps:
Regards,
Daniel
Thank you I will try this. I was actually just working on creating a single input param that is a piped string and then using Split_String to break it back apart. Going the JSON route seems cleaner so I will change my logic to use that.
Hi Josh and Daniel,
I was just trying to recreate this out of curiosity, but I'm not even able to recreate the problem.
This is reactive, right ?
I built a demo app, where I thought maybe updating the structure as a whole instead of each attribute would be a solution to this, instead of having to serialize...
But even updating individual attributes in a structure or a record, don't seem te trigger the onparameterschanged more than once. At least that's my impression, I use a counter to measure it, and counter only upps once per test.
So when exactly does this become an issue, maybe it's because my structures I've tested with are not complex enough.
Josh, when you say change at the same time, this is not within the same action ?? As in an onChanged triggers another attribute to change, or something ??
See attached demo, as far as i can tell, updating multiple input values doesn't trigger onparameterschanged multiple times. Not even if the block has individual input parameters.
Just curious,
Dorine
Yes it was reactive and my application was consuming a web block that initially had 3 text inputs. In the parent block as I updated each text input the debugger step in the onParamChanged step would fire. (it wouldn't complete all the way because the next assign triggered OnParamChanged to fire again)
So then I changed the Block's input parameter to a structure of those 3 text elements. Again, in the parent as I updated the assignment for each element the OnParamChanged handler in the block fired.
Now that I have a single input and I'm doing the JSON serial when I debug I only see the OnParamChanged triggered once.
It is easy to recreate in reactive web and mobile and I have dealt with it in the past. On reactive everything is a sync, if some one enters fast or slow can actually matter on how many time the OnParamterChanged event is fired. This behaviour gets worse if you add code that cost more time to execute in your on parameter change event handler.