Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Stope Double Booking

(0) ShareShare
ReportReport
Posted on by
have a "BikeBook" list where users can book bikes. When a new item is created, I want to check the values of BikeName, BookingDate, and BookingStartTime. If another item is created with the same BikeName, BookingDate, and BookingStartTime, the item should not be created, and an error message should be displayed. I want to prevent double booking for the same bike, on the same date, and at the same time. How can I achieve this using Power Automate?
  • Expiscornovus Profile Picture
    Expiscornovus 30,927 on at
    Stope Double Booking
     
    Normally my suggestion in this scenario would be to not use Power Automate for this, because the item is already created. So, you are not preventing it from being created but you are checking if it is duplicate and deleting it afterwards.
     
    If you really want to prevent that it is being created I would suggest to handle the input side of things (in other words the form). In that case a Power Apps app would be a way of dealing with this requirement. In that product you can validate the input before actually are creating the item.
     
    However, if you still want to delete duplicates afterwards you could use a Filter Query in a Get Items for that in a Power Automate cloud flow.
     
    Below is an example of that approach.
     
    1. The below is used for the Filter query of the Get Items. It checks that other items don't have the same ID and if the other fields are the same. 
     
    (ID ne @{triggerOutputs()?['body/ID']}) and (BikeName eq '@{triggerBody()?['BikeName']}') and (BookingDate eq '@{triggerBody()?['BookingDate']}') and (BookingStartTime eq '@{triggerBody()?['BookingStartTime']}')
     
    2. In the condition a check is done if any duplicates are found
    length(outputs('Get_items')?['body/value'])
    3. If that is the case, the newly created is deleted. Make sure you select the correct ID from the trigger action.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,161

Leaderboard