Hey @kirons -
Sorry about the delay on this. Took a fair bit of investigation and conversation with the engineering side to address this one the right way. Unfortunately this is something that is more on the widget builder in most cases, and just a best practice we need to better document.
Underlying root cause-
The load order is inconsistent, when the CW loads before the variable (we see this more with aggregations) so the prop is incorrect.
Correct resolution-
All widget props should be responsive to changes. There is no deterministic way to predict when the variable/aggregation will load on the app side, so we cant wait for that to happen before loading the custom widget. If your aggregation fails to load, we can’t just not load the custom widget. This is breaking the underlying concept of reactive JS frameworks.
What this looks like in practice, is each prop should have a callback function for when they change. An example of how to do this is in the Knowledge Base article on custom widgets (Custom Widgets Overview | Tulip Knowledge Base - Support for Building Operations Apps).
//Do something anytime a prop value changes
getValue('My Prop', (internalVariable) => {
doSomething(internalVariable);
});
When “My Prop” changes or loads, the doSomething function will be called. I end up with an update function in most of my custom widget that is called by this getValue that just gets the value of each prop, and updates my custom widget.
getValue('Prop 1', () => {
update();
});
getValue('Prop 2', () => {
update();
});
getValue('Prop 3', () => {
update();
});
function update(){
$("#Prop1").html(getValue("Prop 1"));
$("#Prop2").html(getValue("Prop 2"));
$("#Prop3").html(getValue("Prop 3"));
}
If you share your custom widget here (or in a DM, if you’re more comfortable with that) we can look at it and help implement this.
Does this make more sense? Definitely getting into the weeds of why Tulip was created, to remove the need to understand the intricacies of app building.
Pete