I seek your attention for the workaround which I have developed. I am requesting you to test the workaround for the consistency and comment about its reliability . If it is reliable method then I will post in TIPS and TRICKS of appsheet community. I sincerely thank you all for helping me to achieve this.
@scott192 @Suvrutt_Gurjar @AleksiAlkio @TeeSee1 @WillowMobileSys @MultiTech @Koichi_Tsuji @Aurelien @lynchk21
What I have did :
-
I have created a test app which has one simple table.
-
It has column [ SL NO] , and other some columns like name, date, etc .
Note : a special column [ KEY] is added and it was set as key column of the table.
- A bot was created with name : Set SL NO with wait condition
Bot configuration : When this EVENT occurs: When a row is added
Process :
Step 1 . : Check for previous row condition
Expression logic used : checks the table has only one record if not checks the previous row column [ SL NO] is not blank.
The expression assistant shows the error for the expression while saving the editor, error did not stop the app functioning.
Step 2 : Set SERIAL NUMBER ( this branched step is executed if the previous row column [SL NO] is not blank).
Set these column(s) expression :
Step 3 : Wait for the condition (ISNOTBLANK).
Condition is :
The expression assistant shows the error for the expression while saving the editor, error did not stop the app functioning.
Expression Logic : Checks the previous row column [SL NO] is not blank.
Step 4 (last ) : SET SERIAL NUMBER .
same step 2 is repeated.
Logic behind this workaround :
whenever new row is added by multiple users. when the table has the key column with initial value as UNIQUEID(), it will not overwrite the row and instead it creates new row for the each record.
Now the column [SL NO] has to be filled with sequential manner without duplicates and repeating of same number.
Firstly the step 1 checks whether the table has only one record, if yes step 2 is executed if not the bot checks for previous row [SL NO] column whether it is blank or not . If it is not blank step 2 will be executed and If it is blank step 3 will be executed.
Step 3 is a wait condition step , until the condition is met other steps are not executed. if the condition is met it will execute the step 4 .
Lets have an User case with 3 users concurrently :
- when 3 users adds a row concurrently ( which means server will receive 3 new rows) . these 3 rows are not overwritten due to the UNIQUE ID () present in the key column .and automatically it triggers the bot 3 times sequentially .
now bot starts its work.
During the time of adding the 3 new rows to the database, [ SL NO] will be blank.
step 1 will be executed which checks for condition. step 2 : SERIAL NUMBER is set since there may be new or some records in the database.
step 3 is applicable to the 2nd and 3 rd record / row. it will wait for the condition since 1st record [ SL NO] will be blank. once the previous row [ SL NO] ( ie. 1st record [SL NO]) is not blank , step 4 ( SET SERIAL NUMBER) will be executed. It is a kind of queueing the numbering system.
With Regards
Jaichith J