Is it possible that to change other row values when particular row changed, added or deleted in appsheet.
Scenario:
I have products table and its images referenced to other table called images. Images table has 2 main properties: image and status. There are only 2 statuses: main and secondary. In a single product can have many images but with only one image with main status. Other images apply secondary status. How to change one of the secondary image status to the main status and existing main image status to secondary image status?
So like this:
I have 5 images related to single product:
image_1. secondary
image_2. secondary
image_3. secondary
image_4. secondary
image_5. main
I want to edit image_3 to main status and get following result:
image_1. secondary
image_2. secondary
image_3. main
image_4. secondary
image_5. secondary
Here in the screenshot, I added 3 images with first one as “Main” (Asosiy) and other “Secondary” (Qo’shimcha).
When I change let’s say 2nd image status to Secondary, program should set other images’ status as “Secondary”. (Shown in screenshot below)
How to do that?
P.S: I did image status changing by editing first image status to “Qo’shimcha” (Secondary) and second one to the “Asosiy” (Main) manually.
You need to use actions to select the “other” row with status = main and adjust its status to secondary. There are 2 ways:
-
A button - show a button of Grouped actions, maybe named “Make Main”, on only those rows with secondary status. When it is tapped, the first action sets the status of that row to “main” - for now 2 rows have main status - and the second action adjusts the status of old “Main” row. This second action would be of type “execute an action on a set of rows” and the Referenced rows property would select the old row and set its status to secondary.
-
Edit the row - You can then attach the second action described above to the Form Saved property in the Form view.
You could of course implement BOTH of these options!
This is very high level description. If you need more help just ask!
I hope this helps!
Yeah, that was complicated answer.
I am stuck “execute an action on a set of rows” part of your answer.
Firstly,
I created an action called “Make main”, as you said. And it does grouped actions when triggered. Grouped actions are “change to main” and “Make secondary”.
"Change to main"action set the status to the “Main”
Now, “make secondary” action:
Referenced rows are the rows where image status is main and [_thisrow].[id]=[id]
Referenced action is “Change to secondary”, it is shown below:
I saved this, and when I tap to Make main button it is not doing anything, it is showing number 2 on the sync button but nothing is changing.