Re-evaluation of expression after sql query finishes executing

Hi everyone! I am working in 7.9.3. I have what could be considered a race condition issue. Maybe someone has a creative workaround. Here is the setup.

I have a screen that is passed a dataset of recipe information. There are text boxes and dropdown lists that use the lookup expression to auto populate information from the recipe data set.

The issue is with the dropdowns. The data property is bound to a SQL query. The lookup is on the selected label property. I cannot get the dropdowns to consistently populate with the correct information. It appears that the lookup expression finishes evaluating before the SQL query, and the query overwrites the result of the expression.

Does anyone have any insight as to how I could get the lookup expression to evaluate after the dataset fills, or cause the lookup to re-evaluate after the dataset fills?

My understanding is that the lookup expression is always being evaluated (because it is a binding).

What is the direction of dataflow? Is it SQL query -> Lookup expression?

Expressions only evaluate when something it is referencing has changed.

Ideal dataflow would be window opens, dropdown query finishes, lookup expression evaluates. The tricky part is that the dropdown lookup is not referencing the dropdown dataset so it does not re-evaluate.

That’s your problem. There has to be such a reference. Bindings evaluate once on window creation, then again only when one or more of their references change.

Phil, your comment may be the kiss of death for my thread :joy:.

I tried referencing the dataset in the failover value of the lookup something like isNull(dataset[0,0]), but then the referencing becomes circular and I cannot change the dropdown value anymore. There used to be a hasChanged expression that I was hoping to play with, but it is not available any more and I image the results would be similar to the isNull idea.

You’ll have to explain your setup in more detail. Circular references are a logic flaw – something about how you’ve set up your UI is an impossibility.
You might need to derive your dropdown’s dataset of choices from the recipe dataset passed to the window, instead of having the dropdown run its own query. What is the dropdown supposed to be picking?

Also consider not binding the dropdown’s selected value. Instead, add a custom property that you bind to the recipe via lookup. Then use a propertyChange event script to copy from that custom property to the selected value property any time either the custom property or the dropdown’s data changes.

The dataset queries distinct values for that ingredient. The text used to be user entered, and naturally we have 3-5 values that are intended to be the same value ex. “Chocolate Chips”, “ChoclateChips”, “ChocoChips”. Going forward the client will be able to manage the visibility of what is available in dropdown, but we want them to know they used “ChocoChip” last time instead of the no return value of " ". The circular reference comes from how we were handling this while populating the dataset.

SELECT ingredient
FROM parameter_table
SELECT 'dropdown.selectedStringValue' as ingredient

The selectedLabel expression uses the component name to find the value for that ingredient.

lookup({Root Container.recipe},, "no return value", "component_name_column", "ingredient_column")

When the no return value references the data property, the reference become circular since the change in selectedStringValue will cause the query to re-run. This in turn won’t allow any value change. It will continuously re-evaluate to the value contained in the root container.recipe dataset.

I have thought about passing the dataset from the same method that populates the recipe dataset. I think this is the only way to ensure the dropdown dataset is populated before the expression evaluates.