cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Sharepoint list subtract available slots based on dates and time slots

Hi, pretty new on PowerApps. But got a project, needs to keep track COVID-19 testing slots, 40 slots each day, 10 testing every two hours, from 8am -5pm. I was thinking to have two sharepoint lists. One collecting client info, the other list of dates, time slots and available slots. When one appointment is booked, it subtracts 1 from that time slot, I.e. from 10 to 9, till available slots becomes 0. What is the best approach ? Flow? Or use patch, updatecontent?

thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Thanks @lras120265 ,

Firstly forget about the Patch for the moment - that is a completely separate operation.

Put this on a button and see it it works

UpdateIf(
   COVID19TestAvailability,
   TimeSlot = DataCardValue62.Selected.Value &&
   DateDiff(
      TestDate,
      DataCardValue61.SelectedDate,
      Days
   ) = 0,
   {AvailableSlot: AvailableSlot - 1}
)

If not, put this in the Text of a label (anywhere on the screen) to see if you can the the current AvailableSlot number

Lookup(
   COVID19TestAvailability,
   TimeSlot = DataCardValue62.Selected.Value &&
   DateDiff(
      TestDate,
      DataCardValue61.SelectedDate,
      Days
   ) = 0
).AvailableSlot

 As a matter of interest, where are you situated (I am in Queensland, Oz)?

View solution in original post

20 REPLIES 20
Highlighted
Super User III
Super User III

Hi @lras120265 ,

You don't need a Flow - you could do it all with Patch or UpdateIf statements.

Ans yes - two lists for clients and times would be the best approach.

Once you have built this, happy to clarify any particular code issues you may have.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Highlighted

Thank you for the quick reply.  I created two lists, one for client info, including Test date(date time), timeSlots(drop down)(8-10, 10-12, 1-3, 3-5), the time slots list including Test dates listing all May’s days and 4 time slots for each day, and available slots of 10 for each time slot.

Now,  how can I pin point the day and time frame to subtract? 

 

Thanks again

Highlighted

Thanks @lras120265 ,

What does your Power App look like displaying these?

Highlighted

First form has two questions, once they answered (have at least one symptom), will go to second form, with all the client information on it, a lot of questions, then goes to third form, it has time and time slots for choose from, click Book test. I could submit everything to client list, but having issues to subtract the total number of slots on the second list. 

Highlighted

Thanks @lras120265 ,

So to be clear in my mind the second list has all slots for each day as separate records and you are simply trying to mark that slot off as booked? If not what is the structure of the second list?

 

Highlighted

 
 

Correct, I attached the screenshot. This is onselect on "Book test"

 

Patch(
COVID19Screening,
Defaults(COVID19Screening),
'Initial Form'.Updates,
EditClientForm.Updates,
ChooseDateForm.Updates
);NewForm('Initial Form');NewForm(EditClientForm);NewForm(ChooseDateForm)

Highlighted

Thanks @lras120265 ,

Now I can see the List structure, you want to subtract 1 off the AvailableSlots?

Your code is making a new record - I assume in a list separate to this. I will not deal with this code if it is working for you but it does not appear to be specifying fields to Patch to.

However using a List name of TimeslotList (change to your name) and assuming you have TimeSlot and TestDate values also available on the record screen you are patching from, you could do something like this - this one is based on screen control values.

UpdateIf(
   TimeslotList,
   TimeSlot = YourTimeslotControlName.xxx &&    //xxx depends on the control type
   DateDiff(
      TestDate,
      YourTestDateControlName.SelectedDate,
      Days
   )=0,
   {AvailableSlot:AvailableSlot-1}
)

You could also do this referring to data if it is written (with different syntax)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted

Thank you for the quick reply!

Yes, I used Patch to add the new record to client list .  Is updateif code go after Patch? Patch is used for adding the record to client list, updateif will update timeslotlist, correct?

 

Thanks!!!

Highlighted

@lras120265 

Yes, but totally different operation as it is to another list.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (2,393)