So, this is going to be a long one and a bit hard to explain. I have made my tables return as JSON so I can edit the cells inside of the table. I have three columns that can be edited in each table within 4 tables. One is for Maintenance, one is for Electricians, one is for Laborers and the last for Lube Techs. They're separated by "Craft" into 4 different tables. These tables have 3 columns that will be changed via a dropdown in the cell, options for "Status" being Pending, Approved and Denied. We will stick to just the one column for simplicity reasons.
I made the columns dropdowns by doing the following: I made a view with just a dropdown and then creating 4 params on the view as input: values Column, rowIndex and value and an array named ListOfOptions. I then tied the dropdown props.value to the value parameter and the props.options to the ListOfOptions parameter.
Back to the table - under the tables props.columns I set the Status column viewPath to the view that holds the dropdown. I then set 2 viewParams: value Column with the name of the Column being changed and an array named ListOfOptions with a bunch of options with label and value such as "Pending", "Approved", "Denied" and so on. I found out how to complete this via another forum post.
After creating my first table, my script runs flawlessly. It will change the value to what is selected, update the database, then write a log into my log table. However, once I added the scripting to the second table (same exact script, only changing the refresh binding at the end) it wants to change both tables at once to the same selection. Here is my script inside of the props.selection.data.0.Status, for example:
#Variables
FirstName = self.props.selection.data[0].Fname
LastName = self.props.selection.data[0].Lname
ClockNumber = self.props.selection.data[0].EID
Status = self.props.selection.data[0].Status
if self.getSibling("Table Dates Selected Label").props.text == self.getSibling("Sat Button").props.text:
Date = self.getSibling("Saturday Date").props.formattedValue
elif self.getSibling("Table Dates Selected Label").props.text == self.getSibling("Sun Button").props.text:
Date = self.getSibling("Sunday Date").props.formattedValue
else:
Date = self.getSibling("Check Signup").props.formattedValue
Today = system.date.now()
Time = system.date.format(Today, "MM/dd/YYYY hh:mm:ss a")
userID = self.session.props.auth.user.userName
if currentValue.value == 1 and previousValue.value != 1:
Type = "Approved"
LogEntry = userID + " set " + LastName + ", " + FirstName + " (" + ClockNumber + ") overtime to approved for the date of " + str(Date) + "."
elif currentValue.value == 2 and previousValue.value != 2:
Type = "Denied"
LogEntry = userID + " set " + LastName + ", " + FirstName + " (" + ClockNumber + ") overtime to denied for the date of " + str(Date) + "."
elif currentValue.value == 0 and previousValue.value != 0:
Type = "Pending"
LogEntry = userID + " set " + LastName + ", " + FirstName + " (" + ClockNumber + ") overtime to pending for the date of " + str(Date) + "."
params = {"FirstName" :FirstName, "LastName" :LastName, "ClockNumber" :ClockNumber, "Status" :Status, "Date" :Date}
logParams = {"Time" :Time, "LogEntry" :LogEntry, "Type" :Type}
#Runs query to update database table
system.db.runNamedQuery("Overtime/Trade Tables/Status Update Query", params)
#Runs query to add to log
system.db.runNamedQuery("Configuration/Logs/Log Entry", logParams)
#Refreshes approved counter
self.getSibling("Lube Techs Approved").refreshBinding("props.text")
I'm not sure if it's the "self.props.selection.data[0].xxx" that is hitting on multiple tables for some reason or what is going on. It doesn't really make sense to me though as it is a self property. All the Status Update Query does is set the Status = :Status where "FirstName" = :FirstName and "LastName" = :LastName and "ClockNumber" = :ClockNumber and "Date" = :Date.
Thank you in advance for taking your time to read this post and helping out.