-
Goal: I have two database sheets, A and B, as well as a table displaying the information stored in sheet A. I would like to have a textfield show information stored in my database B based on the entry that is selected in the table. The information that is supposed to be displayed in the textfield (data from sheet B) is not shown in the table itself, but the entries in database sheet A are each connected to the entries in database sheet B via foreign keys. I therefore want to (1) select a row from the table, (2) have a query connect the entry selected in the table (from database sheet A) with the corresponding entry in database sheet B, (3) have a specific attribute from database sheet B exported and shown in the textfield.
-
Steps: I tried to reference the ID of the row selected in the table via selectedRow.id in my query and then select the entry from database sheet B via a JOIN query. Because the output of the query was empty, I switched to storing the ID of the row selected in a global variable and called this variable in my query as the new reference key. The result was the same. A fixed ID reference (e.g. 2) works just fine and delivers the output from database sheet B that I am looking for. I also attempted to use variables in different scopes (globally or page-specific).
-
Details: As already mentioned, I am using a table and a container with a textfield inside.
My query code looks like so:
SELECT
to.name
FROM
test_case tc
JOIN test_opponent to ON tc.opponent = to.id
WHERE
tc.id = CAST({{ variable1.value }} AS INTEGER);
variable1 is set globally via a Event Trigger when a row in the table is selected:
variable1.setValue(table1.selectedRow.id).then(() => {
console.log(variable1.value);
});
setTimeout(() => {
query3.trigger();
}, 200);
The console shows the following:
23:56:00
`[`
`table1] `
1. {pluginType: "State", value: 2, id: "variable1", _desktopMargin: "", _mobileMargin: ""…}
![success](data:image/svg+xml,%3csvg%20width='14'%20height='14'%20viewBox='0%200%2014%2014'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='14'%20height='14'%20rx='7'%20fill='%23118848'/%3e%3cpath%20d='M5.94505%2011L3%207.5L5.94505%209.25L7.5%207.5L11%204L5.94505%2011Z'%20stroke='white'%20stroke-width='1.38223'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e)
23:56:00
▶
query3 ran successfully (0.318s)
query3
from query3 response(query3)
▶in query3.trigger()(query3)
variable1.value: undefinedenvironment: "production"
from query3.query update(query3)
from variable1.value update(variable1)
in run script(table1)
in table1 selectRow event handler(table1)
from user interaction
It seems to me that variable1 is set correctly when a row in the table is selected but not used correctly by the query, which marks it as undefined. I am really not getting what the issue could be, so any help would be much appreciated! Thanks in advance!