I have a project I am working on that involves matching employees from one table with positions in another table and then putting that information into another table entirely. I have 3 separate shifts. Each shift has the some of the same departments in it. What I am trying to do is when a department button is selected the DepartmentTable populates with the required employee info and the positiontable populates with the positions based off what department is selected. I need to be able to have the position from the first table and the employee info from the second table be dropped into the third table and then have a submit button put the information from the third table into a SQL db and clear out the third table.
Or if someone knows of another way to do this in ignition I am all ears. I am attaching a screen shot of what I am trying to do.
Personally, I donāt know as Iād use the 3rd table. I would use the selected values from the tables to create a confirmation popup when submitting to the database. That same submit script can check that both tables have a selected value before doing anything else and throw an error if one needs to be selected. I would think this would be the cleanest option.
Unless you want to be able to submit multiple entries at once though, having the 3rd table isnāt needed. If you do want to do multiple entries then you would need a button to tell it to move the selections to the 3rd table and another to remove any incorrect entry. I would use a custom property looking at the selected row from both tables to see when both are not equal to -1. When they arenāt then I would make the move to 3rd table button visible. With the remove button I would only have it visible when an entry in the 3rd table is selected.
There are a lot of different ways to do everything though, it comes down to personal preference. If you donāt like either of the ideas above you can still do what you described by setting a custom property that looks for when both tables have selected row values not equal to -1. Do a property change script based on that custom property. In the property change script you can create your dataset for the 3rd table. I would either have a dataset with just the header stored in the table when nothing is selected or hide the table until something is selected. In your submit button I would set your table one and two selected row values back to -1.
Yeah, it would need to be multiple entries. Basically, coordinators of each department would login and select their department, from there they would select each individual position and āassignā an employee to it from the second table and then submit each position and employee to the database as a whole. I would think doing each one individually would be very time consumingā¦
Thatās why I tried to mention options. So with that I would do the second option and have the button to move it to the table. In that button I would pull the selected values from the 2 tables then use the system.dataset.addRow() function to add it into the dataset for your 3rd table.
The part that will get complicated is scripting your insert/update query when you submit. Iām assuming you would want to check to make sure the entry doesnāt exist currently so you would need to do a query to compare what your putting in to what already exist. Then create your insert/update queries. You can have it loop through doing the inserts individually but that will take longer and hits your database more. I would have the script build your insert/update queries dynamically so you can limit how many times you have to hit the server.
I would make the position table with extra columns for the employee name / number. Then drag/drop from the employee table to the position table. Example attached.
So I just realized you are using Ignition version 8.0 and I am using Ignition version 7.9.11. My version is on a winows server so I downloaded the free 8.0 verison on my desktop. and was able to access it.
Thank you for that! One question i have though, is that my position table pulls the positions listed from a sql query based off which department button I am pushing. Is that still possible to do like that if I add the additional columns in the position table?
Okā¦ so I added additional columns to the position table that is manipulated from my department buttons and once I selected a different department all the other columns I had created disappeared. So Iām not sure what to do at this point.
Not sure I understand, this is what I currently have:
event.source.parent.getComponent(āPositionTableā).data = system.db.runQuery(āselect Position from HumanResources.dbo.AutoDefectingPositionsā)
There are many ways to do things in Ignition. You just picked a different one than what I was expecting.
event.source.parent.getComponent('PositionTable').data = system.db.runQuery("select Position, '' AS Name, 0 AS EmployeeID from HumanResources.dbo.AutoDefectingPositions")
Nevermindā¦ once I added the additional fields for columns it would not work.
event.source.parent.getComponent(āPositionTableā).data = system.db.runQuery(āSelect Position, āā AS EmployeeID āā AS FirstName, āā AS LastName, āā AS Shift, āā AS Department from HumanResources.dbo.AutoDefectingPositionsā)