Help - Issue updating Datastore with wrong row being updated

I am trying to update a datastore with new values and I’m going around in cycles trying to figure out what I’m doing wrong.

OK, let’s get started.

Table below is stored in a Datastore. When you click on the blue wheel it passes the values of the row to an update section on the screen.
You can see that card ‘444444444’ is row ID 2 in the “DEBUG - clean datastore output” table which is the row I click to edit.

Now when presented with the data in the update section you will see I have a DEBUG output to verify the row that has been passed to the update section.

Here is the update action when I click “Update Card”.


So I get the ID from the DEBUG text input.
I tell it to update the record where the ID is from the DEBUG text input and update the card column in the datastore with the new value from the form.

But as you can see below, it’s updating the first row.

What am I doing wrong?

Thanks,
Ray.

Try removing the value of ‘card’ in the ‘WHICH RECORDS’ section so only the ‘ID’ is used.

Yes, I had tried that before and then the card number does not update at all, even on the wrong row.

Thanks for the suggestion.

Try just putting card without the datastore_cards.data[0], I think you are pulling record 0 from the array with [0]

Hi elpod,

Try as you suggested I believe.!

Still no joy. Fails to update anything.

Thanks for the suggestion.

instead of “datastore_cards.data.card” just put “card”, do the same for the NEW VALUES as well

You need to select your values from the repeat in the data picker, not from the data store …

Just as @elpod explains.

Also why do you have two filters and not just one - the record id?
One more thing. The input values are always strings. If you are filtering a numeric value, please make sure to use the to number formatter when selecting it as a value.

Hi @Teodor,

If I only had ID populated no update happens at all.

How does the filter know which record I passed to the form to update if I select straight from the repeat?

I could be just going loopy from looking at this project for 5 days straight/ 14hrs a day…

I will try again.

Sorry.

Please use one filter only, the id of the record you are updating and if it’s a numeric value and you use form input for that please use the to number formatter.

1 Like

:grin: :grin: When a dev comes to your rescue.

So the issue the whole time was that I was not formatting the ID to Number.

image

I had set the input to Number thinking that was enough,

Clearly it wasn’t.

Thanks to @Teodor and all who made suggestions.

Ray.

1 Like

The form inputs values are always strings, no matter what type is set there. You need to format it where it's being used then.

1 Like

Understood. Thanks.

Yes, the toNumber() issue got me a few days ago too.

Booleans can be an issue too… I’m using numbers in the data store to represent Boolean values the same way the database does… Otherwise you have to convert 0/1 to true/false!

Oh, and am about to come up against dates… Am I recommended to store those in the data store as text? :thinking:

(Unless timestamps… Which I guess should be numbers?)