Create a Trigger to Maintain Lead Visibility

Add a trigger that grants sharing access to the person who created the lead even when they’re no longer the lead’s owner. Granting sharing access enables the lead’s creator to track the referral after it’s converted to an opportunity.

Available in: Lightning Experience

Available in: Enterprise and Unlimited Editions with Health Cloud


Instead of using Lead and Opportunity objects to manage referrals, use the Clinical Service Request object and automation tools built for the FHIR R4-aligned Clinical Data Model. To benefit from new and enhanced referral management features in the future, you must use objects in the Clinical Data Model.

Important

To access the LeadShare and OpportunityShare objects, sharing for the Lead and Opportunity objects must be set to Private or Public Read Only.

  1. From Setup, select Customize and then click Lead.
  2. Click Triggers and then click New.
  3. To define your trigger, enter Apex code similar to this sample code.