Geeezzzz How do you initialize custom parameter/component parameter/embeded view parameter..
I placed my code on Startup Script, I have different result every time..
My initial theory, embedded did not fully loaded, when the init command on startup executed.
I tried Sleep, but still it is hit or miss.
So I did last resort.
On startup, this time I write to View's Custom Parameter (thinking views custom parameter will wakeup same time with startup), then my embedded component's parameter is bind to view's custom parameter..
STILL... View's custom parameter would not initialized.
I tried to Switch Off Persistence on the custom variable.
When the view launch, the custom variable appeared, and with a value from out of no where!! - there should be no value since persistence is Off.
SMH... so I add 2 seconds sleep at the beginning of startup.. works now (i can see custom variable appear with rubbish data, and got initialized.. but really. this solution is not robust.
Does that mean, startup write command is a Miss when the target parameter still not loaded?
Any idea how to properly Initialized components parameter that works all the time?
Use an expression binding that produces a constant. Scripts run in parallel with component operations, and, as you've seen, tend to have race conditions. Use scripts for user-initiated UI events.
I added expression binding to my Custom Parameter(statusId).
if({view.params.isNew},"",{view.params.statusId})
Upon opening the view on designer.
statusId has garbage data of 160. (idk where 160 came from)
And the expression bind to statusId did not run - I had to open the binding, then press ok, then it will update.
This is so frustrating.. Hope can get to the bottom of this.
Worth noting if you press save in designer when you changed a parameter while it's "playing" the view, it will save that as its initial value.
Seems like you just want this statusID
you pass down to be a custom parameter? Can you do a parameter binding to the view.params.statusId
That isn't a constant expression. And it references view.params.
keys that won't be defined on docked views.
Use view.custom.
instead of view.params.
in docked views. Expression bindings driving these need to only reference session props, constants, or other custom props that receive a value "before" them.
Oh, I am referring to a popup view. where I pass in initial data: (isNew, data object)
--edit:
Technically, it is a Popup form, where user start from blank or use the pass is data..
The problem is, when I launch the popup, I can't write to the fields to initialized it.
I need to sleep 2 seconds, and write on them..
Ok. Wrap your references to parameters in coalesce({view.params.whatever}, someConstant)
that will yield a valid, temporary, result prior to parameter initialization.
Make sure parameters are not persistent. That way they are null before initialization, triggering the coalesce()
in the moments before everything is initialized. Some bindings might run more than once depending on the (random?) order of initialization.
1 Like
Thank you..
Instead of startup script, I now use binding on all View's Custom Parameter to initialized, what needs to be initialized. Now the writing down to embedded components (via binding to custom parameters) are successful.
custom properties, not parameters. Terminology matters.
/pedant
1 Like