Updating vs adding a row: how to test? Is th...

(Joseph Pentheroudakis) #1

Updating vs adding a row: how to test?

Is there an easy way to check if I’m updating an existing row as opposed to adding a new one? I have some read-only columns that I increment automatically when I add a new row, and I don’t want to touch them if I’m updating that row (say if the user needs to go back and change something).

I do have a slice for the table that contains all rows saved - how do I check if the row being updated is in the slice (which, if true, would tell me that I’m updating a row and not adding a new one)?

Thanks everyone as always.

(Levent KULAÇOĞLU) #2

Hello +Charlie Wells, You can set a VC with an expression:

IN([KeyColumn], TableName[KeyColumn])

if it evals to TRUE, it means that you are editing an existing record if it evals to FALSE, it means that you are adding a new record

(Joseph Pentheroudakis) #3

@Levent_KULACOGLU thanks! I just realized I can also compare the row number with the max row number in the slice. If it’s larger then I’m adding a new row, if not, I’m updating an existing one. That would work too, right? I’m assuming row numbers are assigned to a new row as the add form is invoked,

even before the row is actually saved?

If not, I could look for a null row number?

(Levent KULAÇOĞLU) #4

+Charlie Wells that will not be the right path to follow. If your table is accepting DELETE, then AppSheet will actually clearing the content of that row from the sheet instead of deleting it where a new record will be added to the first empty row. Thus, with the method you have proposed, you will not be getting the right value for that kinda comparison. But comparing if the key value is in the key column or not, therefore will always be the most robust and guaranteed approach.

(Joseph Pentheroudakis) #5

@Levent_KULACOGLU ah I was wondering how delete worked. I’ll use your method. Sağol! :=)

(Levent KULAÇOĞLU) #6

You’re welcome +Charlie Wells , pleasure to help you. Bir şey değil! :=) Translate