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
ChickenOrBeefChickenOrBeef 

VisualForce: Find & attach existing record, or create & attach new record

Hey everyone,

We have a custom object called "Properties" and a junction object called "Property/Opportunity Relationship" that allows for a Many-To-Many relatiosnhip between Opportunities and Properties. Anywho, I need to create a slick VisualForce section on our Opportunity page that allows our users to  the following:
  1. Search for an existing Property record
  2. If existing Property record is found, then that record is attached to the Opportunity (via the creation of a junction record)
  3. If user can't find existing Property record, they can then fill out a couple fields to create both the new Property record and the junction record to connect it to the Opportunity
Is there any example code out there that does something similar to what I'm describing? Of if not, can someone provide some example code? I have decent experience with VisualForce, but I've never made anything quite like this.

Thanks a bunch,
Greg