Hi @mdsmith1, if I'm understanding correctly, you would like the value of the localStorage key to be the value for a column on your table, for all rows.
Is that is the case, create a new column:
Give it a label, format, and for the value, reference the localStorage key you would like:
Thank you for expanding on this and adding the screenshots!
The "Value" input field on the event handler accepts text by default. To add a reference we defined, we must use the double curly bracket syntax: {{ reference }}. That being said, just adding {{@i}} won't work because the variable is defined within the scope of the query, but we are trying to access the value outside of it.
However, we do have access to queryName.data, which is the output of the query. It will just be a matter of accessing the value.
For example, given the following MySQL query:
I set up a variable @Total_Users that counts how many users I have on the table (3). The output of this query is what was selected, as we can see in the "State" tab:
I think there is a difference in what you are doing and what I am trying to do.
It appears that you are calculating the count of Total Users within the Internet Storage app.
I need to take a value calculated in the front end app and put that into storage.
I have attached some screens:
Screen 1
This shows the application.
Screen 2
This shows the result of @i which is 250
Screen 3
This shows the syntax in "Set local storage".
Screen 4
This shows the result with is "undefined".
My example may be calculated but in my real world case. I need to calculate "Taxes" that takes 20 lines of code. I need to calculate in the front end code and put that into storage.
From the first screenshot, @i:=0 is the key in the data object. If you click where it says @i:=0 (on the "State" tab) we should be able to see the value of what was selected. "[] 1 item" means the value of this key is an array with one item in it. Could you show us what is there when you expand that key?
If inside the array (the value of @i:=0) we find the value we are trying to add to "localStorage", we would need to update the "Value" of the event handler as well.
Instead of {{Test02.data["@mTest:=@i"]}} we need {{Test02.data["@i:=0"][0]}}, where Test02.data is the object that we get as a response of the query, "@i:=0" is the key we are 'keying into,' and [0] is extracting the element at the index of 0 in the array.
There is only one value for the key, and it is [0]. In other words, @i:=0 = [0] where @i:=0 is the key, and [0] is the value. We cannot access the index of 2 because there is only one element in the array, that is why you are getting undefined again.
This is because the query is running a SELECT @i=0, this is returning the value of @i when it is assigned (0).
Let's take a step back.
The query that you are running sets the value of the "f12" column in the "letter02" table. For each row, it sets the value of f12 to the current value of @i and then increments @i by 10. Essentially, it assigns consecutive values starting from 0 (the initial value of @i) to the "f12" column in the "letter02" table, with an increment of 10 for each row.
If I am understanding correctly, you would like to get the value of the variable after it has updated all rows. In the case of having 3 rows, that would be 20 (0 -> 10 -> 20).
If this is correct, we will need to create a new query that gets that value of "f12" from the last row, and then we can add it to localStorage.
If your table has an auto-incrementing primary key column, you can use that. Assuming you have a primary key column named id , the query would be:
SELECT f12
FROM letter02
ORDER BY id DESC
LIMIT 1;
If you name this query "getLastF12", you could run this one on success of the "Test02" query. Then, on success of "getLastF12", we can add the event hander to "Set local storage", and the value would just be {{getLastF12.data["f12"]}}.