Was hoping someone could help as I can’t work this out…
I am trying to update some data in a pre-existing table (in the ‘else’ condition where the data already exists).
I can’t work out how to get the update to happen to the correct row because I don’t know how to set up the ‘row ID’ correctly.
I’m getting the error ‘Variable is out of scope’ when I try to refer to the Row ID from before. Please see screenshot here:
A couple things are happening here:
- A cloud variable requires a name for the Firebase path to that value. So typically that would be something like “/Users/UserId/data” but you’ve give it a row id which is a string of characters referring to the specific row of a data source. Firebase doesn’t use row ids.
I’m not sure why you’re using cloud variables… you can probably do the same thing with an app variable.
- The row id is “out of scope” because you used a green block outside of its function or event block. So the green
row id only contains a value inside of the
create row block. If you want to use that value outside of it, you need to assign in to a variable.
For the row id value in the
update value block, you can use an integer or you can retrieve the row id from the
list of values block by selecting “ID” from the column drop-down menu (the one that shows “email” in your screenshot).
Thanks so much for your reply.
I can definitely see that I’m building this incorrectly, but am struggling a little to work out the right approach here.
What I’m trying to do is fairly simple. It’s basically to allow users to add some information (which gets stored in a database). And if they they’ve already saved some information, then they can update that. Simple as that for now.
I’m using Google Sheets as my database and Firebase as the authentication.
Is there any good tutorials you know of that can explain the right approach to building this?
My approach would be to assign a variable such as app variable foundRowNum to the
find first occurrence of block to search the list of values in the email column for the user’s email address. That block returns a 0 if nothing is found and an integer representing the row number where it’s first found in the column if it does find it. So you can use the result in an if/else block to say if that variable is greater than zero, update the value in row id [app variable foundRowNum] … else create row.