I am trying to create an item queuing system for fun.
But got confused on how to relate it in the builder and automation.
So the data is something like this:
P1 (Person 1), needs 5 items A, 5 Items B, and so on.
P2 needs 5 items A, 5 items B, and so on.
So, the input for the app will be something like: 3 Items A; 3 Items B; 4 Items C
Then I want the app to process the input to decrease the amount of the items that the person need, starting from the top from the top.
The output will be those who get the said items: P1 Items A x3, P1 Items B x3, P1 Items C x4
and at the same time, I need to overwrite the source table with the updated data.
Since P1 needs 5 items each from Items A-E, and P1 gets the items just now, I need to know how to make an overwrite so that the number of the items P1 needed are adjusted accordingly. (E.g P1 needs 5 items A, just now he get 3 Items A, so he only needs 2 more items A, etc)
I appreciate any help that anyone can provide. Thanks!
Hi @VinTheo88, thanks for your question!
If I understand you correctly, you're looking to use the app to collect the number of purchased items. Then you'd like to update your table by subtracting the number of purchased items from the initial quantity.
If so, here's one way to do it, though at the moment, we would need to add a few additional columns to your existing table. To explain it, I'll focus on just Item A, but you can apply it to all items.
In your table, add a column for each item where you can store the number of purchased items: [Item A Purchased].
Go to builder and add a list to show items for each person. I used the "Column List" object because it automatically lets you create a detail screen with it. This automatically ties the list screen with the detail screen (learn more here). I also added an "edit" button that navigates to the detail screen.
Go to the detail screen that was made using the "Column List" object. Note the top-most data cell: it is a variable data cell, $[InputRow], that specifies the table row we want to read and write data (learn more here).
Now let's make input fields so app users can input the number of items they purchased. I made the data cell editable, made it a "Shared" source type, and set the shared source using the $[InputRow] and used column syntax to make sure the input field reads from and writes to the [Item A Purchased] column in the table (learn more about column syntax here).
Now let's do the fun part and tie things together with automations! For your scenario, I assume you want app users to submit the number of purchased items when they tap on the "Update" button. To do this, add an automation to the button by going to the "Actions" property tab and create an automation. We want to do a few things with the automation: (a) calculate the updated quantity of the item and (b) reset the input field value.
To calculate the updated quantity of the item, I added an "Overwrite" block (learn more here). In the "Take data from" field, I calculated the updated quantity of the item (again using $[InputRow] to specify the table row and using column syntax). In the "and write to" field, I specified where to save the updated quantity.
To reset the input field value, I added another "Overwrite" block. This time, the "Take data from" field is blank, while I specified the [Item A Purchased] column in the "write to" field.
Finally, to complete the experience for app users, I added a "Navigate" step to the automation, so app users will be taken back to the list screen.
Hopefully this helps! Please let us know if there are any questions!
Thank you so much for a detailed explanation Albert! I will try to replicate today! Thank you eo much!!
I have been trying to replicate the steps that you gave. But I got stuck with this error in step 6 and 7:
Any ideas on how to fix this?
I remade the whole thing, and it works fine!
Thank you so much for your help!
Now I need to figure out on doing this for more items.
Thank you so much!
Hi @VinTheo88, that's great! Thanks!