I have an app I’m working on and I want to make it easier for people to change values from two different rows, to swap between them. For example, imagine you had 20 baskets full of different fruits, but you wanted to record a switch between the contents of basket 7 and basket 12. My app has “activity” records. How would I make an activity record that reflects a swap like the one shown in the gif below?
I think I would have to pre-populate the values for each of the “Fruit in basket…” fields based on each of the dropdowns, but my question is “how do I trigger and show the swap?” Imagine that it’s not possible for a fruit type to be in more than one basket, and that all I need to do is swap (e.g. I don’t need to take just the Pears out of one basket and put them in another). I’m aware of the “trigger” column idea (generally), but how would I do this within a form? I need to let people choose which baskets to swap the contents in.
Is it a multi user app? If so, what if user A is trying to swap from record 7 to 12 and user B simultaneously swaps from 12 to 7 and user C from record 7 to 15 and user D from 18 to 12. How to handle these possible conflicts.
Is it correct understanding that you essentially are looking to swap just one field from one record to other? In your example, multiple fruits are in one field. So is it an enumlist field?
In general, please also be aware that any changes in the form view will reflect in the records only on the form save event.
Yes, I think there needs to be some clarification. If I understand correctly, you want to swap fruit between baskets - basket 7 gets basket 12 fruit while basket 12 get basket 7 fruit.
However, your GIF doesn’t reflect that. The GIF just switches the From/To assignments and makes it appear that what you really want is to MOVE fruit from one basket into another but NOT swap them - e.g. move fruit from basket 7 into basket 12 so that basket contains all fruit of basket 12 + basket 7.
Here is one observation that might help. If you truly want to SWAP baskets, - 7 to 12 and 12 to 7 - , you can EITHER swap the contents of the basket OR swap the basket numbers themselves. To swap numbers, they cannot be the primary key. You would have to use/add another column as the key.
Also, Forms cannot have custom action buttons on them, so this cannot happen in that view. We can do something similar in a Detail views. I believe there are other options as well.
Please clarify what your intention is and we can try to help more from there!
Thanks for your responses, and apologies for my delay in getting back (somehow I don’t get notified when there are responses).
In my ideal case I would have a table called Baskets, and there would be (say) 20 records in that table (20 baskets). Each basket has a “Contents” column which is an enum list of fruits. Then, let’s say, I have another table called “Changes” that let’s a single user (not two at a time) make changes to the contents of each basket. They can create a new record in the Changes table and see a user interface something like what I have in the prototype, albeit with a save button as well (to actually save the change record). Then an automation runs on save that actually goes into the Baskets table and changes the values present in the Contents column for each basket. And I have a record of what changed when (in the Changes table).
I’d have an action called “Swap” that let’s a single user at a time initiate a swap which creates a record in the Changes table and updates values in the Baskets table. I’m already able to do things like “get the existing value from the Contents column for Basket 12 and show it in the Change table form”. But what I’m wondering is if there is a way to actually take the contents of basket 7 and put them in basket 12, while at the same time taking the contents from basket 12 and putting them into basket 7. I’d like to make this possible for users to see before they actually save the change. And I need to make sure the contents of both baskets actually change, not just one of them. I can’t be leaving any fruit on the floor.
Hope that helps to clarify, and thanks again for your responses.
Ok, basing this off your explicit request to physically SWAP contents between two baskets.
First, as stated before you would not be able use a button on a Form View as indicated in your prototype.
There are several alternatives I can think of:
Have a dedicated “Swap Form”. The idea is that the user sets which baskets to be swapped in the Changes Form View and when they tap Save, an action attached to the Form View performs the physical content swapping.
Provide a way to “Select” rows from the Baskets table and Swap them. This uses Inline actions. Have an initial Inline action “Select” rows - achieved by setting a column named “Selected” in the Basket row. Once 2 rows are “Selected”, remove the “Select” Inline Action and show a “Swap” inline action on only the 2 selected rows. Tapping either Swap button, creates the Changes row, performs the physical swap and resets the Selected column - all silently. User sees only the end result in the Baskets table. I would also enhance this to include an “Unselect” button should the user chooses the wrong row or wants to end the swap function.
Similar to 2), provide an inline action to “Select” rows. This time the “Swap” Inline button creates the Changes row but then navigates to a Detail View that shows the Baskets about to be swapped. This Detail View would have its own “Swap” button that completes the physical swap and possibly a “Cancel” button to end the swap action. This gives the user some control to proceed with the swapping or to cancel a reset the selected rows.
We do have the ability to place tables into Edit mode, allow the editing of several rows at once and then saving them with a single Save button tap. If your feature allows, you could have the user place the Baskets table into Edit mode, then make Swaps across several sets of rows, use validation to ensure there are no duplicated sets of fruit across the Baskets and once all set tap Save to submit all changes at once. No Changes table would be needed but if you wished to record the changes, you could use automation to capture the row changes and record them in a Changes table. Assuming the sets of fruit in the baskets always stay intact, this operation would allow for movement of fruit across several baskets instead of just a SWAP. For example, move from 1 to 7, 7 to 12, 12 to 20 and 20 to 1.
Let mw know if any of these interest you or if you want to see a visual of how one would work.
That definitely helps; gives me some good ideas about how I might approach it. I probably lean most toward the first selection you mention. If I have success implementing something useful I may report back here. Thanks for the input!