I have a popup called AddBrassTag
that contains a table, Tbl_Insert_New_BrassTag
. When I enter data into this table, commit the edit (Edit Cell Commit) and press Confirm
, the data is passed to another table called Table
on a different popup, ConfirmSave
.
On the ConfirmSave
popup, there's a "Save" button (BtnSave
). When I press this button, I want to save the data from the Table
on the ConfirmSave
popup into the database using an Insert Named Query
.
Here's the script I'm using to handle this:
def runAction(self, event):
# Retrieve the table data
table_data = self.getSibling("Table").props.data
brassTag_Ins = []
# Iterate over the table data and populate the BrassTag_Ins array
for row in table_data:
if row["BrassTag"]["value"]:
brassTag_Ins.append({
"BrassTag": row["BrassTag"]["value"],
"BrassTag_Desc": row["BrassTag_Desc"]["value"]
})
# Now, assign the populated brassTag_Ins to the custom property
self.getSibling("Table").custom.BrassTag_Ins = brassTag_Ins
# Initialize tbl with the newly populated brassTag_Ins
tbl = self.getSibling("Table").custom.BrassTag_Ins
lastBrassTag = tbl[len(tbl) - 2]["BrassTag"]
# Run the Named Query to save each row in tbl
for row in tbl:
if row["BrassTag"]:
system.db.runNamedQuery("Query_BrassTag_Insert",
{"BrassTag": row['BrassTag'],
"BrassTag_Desc": row['BrassTag_Desc'],
"user": self.session.props.auth.user.userName})
# Clear the table and BrassTag_Ins array after saving
self.getSibling("Table").custom.BrassTag_Ins = []
self.getSibling("Table").props.data = [{
"BrassTag": {
"editable": True,
"style": {"backgroundColor": "white"},
"value": ""
},
"BrassTag_Desc": {
"editable": True,
"style": {"backgroundColor": "white"},
"value": ""
}
}]
Issue:
Despite using the above script, no data is being saved into the database.
I've attempted to store the table data in a custom array BrassTag_Ins
and then retrieve it for saving, but this approach also isn't working.
Request:
Could anyone guide me on where I might be making a mistake or what I might be missing? I appreciate any advice or insights you can offer.
Thank you for your time!