Possible Methods for searching one sql database based on another sql table selection - Final Steps of my project!

So I have been working on a project to showcase how big an impact perspective can make for us and have learned a lot but I'm not sure what methods to choose for this final step and would like some thoughts from more seasoned users. Ideally what functions would you use? I'm going to have to look them up afterwards to understand how to implement them.

I have 1 SQL database that generates order numbers with recipe ID's. I have another database with all of our recipes and target goals for our machines.

I need to allow the user to select the order number that has the recipe ID in a table from a popup window and display target goals on each of the labels on the main screen.

The thought process is:
Select Load Order Button > Pick which order to start from a table > Popup window closes > Target goals are set for each label based on which Recipe ID was selected in the row with the order number.

Here is a screenshot of the UI for reference. The goals should load in the top right corner of each of the boxes.

Are you forced to have these tables in two different databases? Seems like they're so closely related they should be in one.

Regardless, it should be as easy as making two database connections on your gateway, and then the named queries with appropriate parameters, and setting the Database Connection property of the named query to the proper database connection.

There are some changes potentially happening soon with our databases and how things are setup. For demonstration purposes I have one database with two tables setup. One for the order numbers/recipe ids and another with the recipe id's and their target goals for each recipe.

My problem is that I'm picking this language up on the fly so I'm at a point where I don't know what I don't know lol, if that makes sense. I have both tables setup inside the same SQL database.

I was thinking of trying to setup each of the target labels to be set to one tag and filter out the data they need to show via formatting. I'm just not sure how to make that tag update based on what recipe id was selected in the row.

Right fair enough regard the tentative setup and

I'm at a point where I don't know what I don't know lol, if that makes sense

Totally get it lol. Before you even get to the UI, do you have named queries setup, connected to the right database, and they work correctly? You have one query that gives you a list of recipeID's from db1 and you have another named query that gets the targets from db2 based on a recipeID parameter? If not, I would start there.

Yeah I have each of the queries setup already.

The first is: getProductionDayOrders (This pulls the order numebrs/recipe ids)
The second is: TargetGoals (this has the recipe id / target goals)

The they seem to work fine and return all the information I want when testing with tables or filtering out specific data on labels so far.

I see you already have a popup with the all recipeID's for the user to select. When they click on load targets, I would what what the selected recipeID is and feed it as a parameter to your view that has these targets. If this target view is just always open you can also then instead write this to a session property, or use a message handler to get it to thew view.

Then on your targets view, a custom property that is a NamedQuery binding to TargetGoals with the recipeID as the parameter, wihch may be from your session property onw if you did it that way, or perhaps it's a different custom property you populated with a message handler.

Now you have your dataset of targets and you can easily bind from here. The normal expression I use to bind is like try({view.custom.targetDS}[0,'someColumn'], 'defaultValue'), assuming targetDS is the name of your custom property with the target goals data. 0 is the row to grab from, 'someColumn' is the colum to grab from, and 'defaultValue' will show if for some reason trying to access that value throws an error.

That's how I would do this, I don't know if anyone else has any easier suggestions.

have you seen any examples of this so I can try to learn by deconstructing the code?

I don't, IA might, but if no one has shown you yet, this is a great way to learn all about Ignition, you may want to skip right to the perspective module though a solid base in python goes a long way - https://www.inductiveuniversity.com/

oh yeah, I have been living there the last week or two. Watching what I can. Its been a huge help.

So I found a way to do what I want. I'm not sure if its the most efficient way to do it but here is what I did.

  1. I used a payload function to send the recipe id back to the main window.
  2. I used 6 labels to act as visuals for the target goals and setup the labels to check the recipe id label for specific ids and to change the recipe id value to the target goals.

This seems to be working smoothly for me with no issues.