I'm creating an ebay style app: 1 product to sell, 3 pieces available but 10 possible buyers.
Each buyer can buy max 1 item.
DB: I have a list in sharepoint with the yes/now column of the product to sell.
CLIENT: I created the app where you see the yes/no check and you can choose to buy or not. I added a label showing how many pieces are available (3 minus count of shp list column).
I have a countdown timer that refreshes the source every 2 secs so that the remaining pieces field is always updated.
Now I thought I could do a check before submitting the form so that it does not patch the list if the product is finished during the latest 2 secs.
What if 2 concurrent users click on submit ? Is there a kind of special powerapps function / caveout to avoid "overbooking" ?
This could be done as follows:
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.Give it a trial. Details of your datasource would help
I don't see where concurrent sessions are managed.
I was actually thinking of having another sp list with the products availability where the sp column is a number where the minimum possible value is zero (see sample below).
I expect that when you try to reduce that value you got a kinda error which I could pick up from powerapps.
If error, no patch.
Any idea to catch that error ?
I found this below but it's not catching anything.
If( IsEmpty( Errors(ProductList, Patch(ProductList, ...
I would also need a way to decrease the value without calculating it's existing value.
I mean, if I click on submit and the current value is 3, my submission will say "3-1=2" and it will be ok.
If someone else clicks on submit in the exact same moment the current value will still be 3, and his submission will also say "3-1=2" and it will be accepted too cause it won't raise any error since it's not minus zero (still if I solve the error issue above).
Now, instead of having to calculate the current remaining, can I just trigger the decrease ?
I mean, when I click the formula should say "decrease that", not "grab the current value, remove 1 and update it". (I hope I explained myself)
It looks like somebody asked if I solved the issue but the question was removed.
So I first had a working situation like below but it got **bleep**ed up somehow.
I had two lists, one with users and a yes/no column for any product chosen and another list with the maximum pieces available.
By using the oncheck and onuncheck fields of the toggles, I could do:
- oncheck: if no error while patching the list of available pieces and reducing the max available number by one (minimum allowed number is zero), then patch also the yes/no field of the first list for current user.
- onuncheck: just patch both list by adding a 1 to the available pieces and set the right yes/no value on the other one.
But it worked for maybe 2 mins then buum !!!
Really no idea what's going on
I'm back to the countif solution now. I wish this thing was open source..
Check out new user group experience and if you are a leader please create your group
Check out how to claim yours today!
Test your skills now with the Cloud Skill Challenge.