Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.

Differenciate new and updated record within one single bot

Aurelien
Google Developer Expert
Google Developer Expert

Dear Community and AppSheet Champions 🤠

Among the suggested bots, we have the suggested event "A record is created or updated".

I would like to be able to differenciate the two situations, without having to create one bot for each single-event data change.

I thought about this, but that does not work:

Aurelien_0-1677170982620.png

Would you happen to have an idea?

Solved Solved
0 15 1,164
2 ACCEPTED SOLUTIONS

Maybe not very economical  as it involves adding a column 🙂but the following works .

Please add a ChangeCounter type column , with Accumulate mode and initial value as 0 that changes on all column changes or you can set the columns you want to designate as "Update Changes"

Then your branch condition for add/update can be 

AND([_THISROW_BEFORE].[TESTCOUNTER]<>[_THISROW_AFTER].[TESTCOUNTER], [_THISROW_AFTER].[TESTCOUNTER]>1)

[TESTCOUNTER] is ChangeCounter type column here.

The Y branches to Update record Email and N branches to Add Record email

Suvrutt_Gurjar_0-1677174060210.png

 

View solution in original post

If I may add further, my testing leads me to believe that there is no concept of [_THISROW_BEFORE} or [_THISROW_AFTER] before a row is created or added the first time. This is logical because the row itself is non-existent before adding.

The help article's  and its title also confirms that the said values are for updated record.

Access column values before and after an update - AppSheet Help

Even the expression that worked in the test app, essentially  checks if the row is updated  ( A combination of [_THISROW_BEFORE]  , [_THISROW_AFTER]and  ChangeCounter column being >1)  and if the results is FALSE, then it considers  as the row is added and it works. The point to note is detection of add condition  ( A FALSE result of the expression) is indirect. If it is not updated, consider it added.

Hi @Aurelien ,

On second thought, I think even the following simpler expression will work in the branch condition. I have not tested it though.

[ChangeCounter] =1   

TRUE means record is added ( [ChangeCounter] updates to 1 on record add) and FALSE means ( It is greater than 1) and record is updated.

View solution in original post

15 REPLIES 15
Top Labels in this Space