TransWikia.com

How to check if a records exists for a date range in Flows

Salesforce Asked by Prerana on October 4, 2021

I have a flow to "Add a Reservation" from Account. The user needs to select the site (Lookup to Account – type site), Asset (Room) and enter the start and end date of the reservation.
Screen 1

Screen 2

I am having issue checking if there is a reservation for the same site, same asset between the entered start or end date. The trouble is with the date range.
My flow looks like this:
Current Flow

My getReservation filters looked like this: (This just checks if there is any reservation between the start and end date you entered, which is wrong. I want it to check if the dates I entered is a part of any existing reservation)
enter image description here

I tried something like the below, where I tried to get all CONFIRMED reservations for that site and asset. I tried to iterate over this collection, then I placed the decision component to check if my start or end date falls in between any of the existing reservation’s dates. I am not sure how to close or end this loop.
In BUild - Flow

My filters for the decision is :
enter image description here

I want to know if this approach is correct or can this be done in a much simpler way?
I would appreciate any help in this!

Thank you

One Answer

You are querying multiple records in the Get Records element getEligibleReservation. However, the loop Loop Reservation only checks for the first record and redirects it to either Confirmation or Duplicate Reservation screen.

Delete the connector No existing Reservation that connects to the Confirmation screen. Instead, connect this back to the loop Loop Reservation. There would be one more connector coming out from the loop After last Item. Connect this connector to the Confirmation screen.

Now, we are checking for all records in the collection. If there is a record with an existing reservation, the user is redirected to the Duplicate Reservation screen. If there is no such record in the whole collection, the user gets redirected to the Confirmation screen.

Correct answer by Prakhar Saxena on October 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP