Using value from one dropdown to query values for another dropdown

This has to have been done before. I’m using Vision. Says v8. I’m actually jumping into Ignition for the first time as I have joined a new company that had it but it was left unmanaged for 5 years. Trying to pick-up and learn and create new projects and try to finish some of the ones left outstanding.

I have a dropdown1 that queries a column and brings back all the values. Easy.

I then select a value from dropdown1 and want to use that value to query the values of another column and dump it into dropdown2.

I bound dropdown2’s selectedStringValue to dropdown1 and made a Named Query where it literally is:

SELECT val2 FROM table WHERE val1 = :selectedStringValue

Doesn’t work. Says there’s a syntax error around the “:”

Then tried: val1 = 'Root Container.dropdown1.selectedStringValue'

Says there’s an error around Root.

What the heck am I doing wrong?

Use the property browser to get the path.

But don't leave it as a basic query. Convert it to a Named Query, as curly-brace interpolation is unsafe.

2 Likes

How did you define the named query? The parameter in the query, must match the name of the parameter as defined in the named query.

A named query will not recognize a vision component path.

Once you have the named query, you can create a named query binding. Selecting the path to your named query, will then populate the parameters table with the parameters defined in the named query. You can then use the property browser in the value column of that table to bind the selected value of the dropdown to the parameter.

2 Likes

This works if I bind from the Property Editor at the Data property.

However, if I copy and paste the SQL command into a Named Query, it doesn’t work.

I get an error.

Right, named queries are different. Parameterize the variable in the query like @lrose is speaking to above.

Ok, got it working now. Just had to hit the easy button and select the ‘Convert to Named Query’ in the property binding window instead of going to the actual Named Query in the Browser and creating from scratch, like how pturmel mentioned.

Still getting used to this software, lol