function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jeremy CJeremy C 

How do you filter a lookup list based on records in another object?

Task: Create a (very basic) reservation system for vehicles.
Reqs: User enters date for reservation and clicks submit. A list of available vehicles (not reserved for that day) are displayed. User can then select an available vehicle and enter the drivers name and save.

Approach: 
1. created a reservation app, includes pickup date, vehicle list, and driver's name
2. created a custome vehicle object used a lookup in reservation app

Problem:
How do you 'remove' the vehicles that are already reserved for a specific day

Example
I have Ford, Chevy, and Dodge truck records in my Vehicles custom object. This list is currently used as a lookup in the Reservations app. There are already several reservation records entered. The Ford truck is reserved for 12/31/2017. If I enter 12/30/2017 I see all three vehicles but if I change the date to 12/31/2017, I only see Chevy and Dodge as being available.

Any assistance appreciated. (Not sure if this is the correction disccusion topic)
RD@SFRD@SF
Hi Jeremy,

This can be done by setting a look up filter.
Steps you would have to follow would be.
1. You ll need a status field on Vehicle object. Say with values "Booked","Available"
2. When ever a reservation object record is created with a start date and end date. Write a process using process builder to trigger two time depenedant actions.
       a) One on the start date, which updates the selected vehicle record in Vehicle object, status field as "Booked".
       b) Second one on end date, which updates the selected vehicle record in Vehicle object, status field as "Available".
3. This status field would help us to filter out the booked vehicles. On the Reservation object,go to the vehicle lookup field and add a lookup up filter to it, to show only the vehicle with status as "Available".

Please follow the link (https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=0ahUKEwitivzNx9_RAhWJs48KHfPuCEwQFggeMAE&url=https%3A%2F%2Fresources.docs.salesforce.com%2F200%2Flatest%2Fen-us%2Fsfdc%2Fpdf%2Fsalesforce_filtered_lookups_cheatsheet.pdf&usg=AFQjCNHKRjptdsB5Xx_Ign9B705i1gOzZA) to read more about lookup filters 

Hope this helps

Regards
RD