+ Start a Discussion
Stephanie Boggs 17Stephanie Boggs 17 

Compare field on Lead to all values in corresponding field on Account

I am thinking that Apex is my only hope for this, but if this can be done without let me know!

I have a formula field on the Lead that pulls the email domain (i.e. gmail.com) (Email_Domain__c) from the email field. I have a field on the Account that contains the primary email domain via a text field (Primary_Email_Domain__c).

When a Lead is created, I want to compare the Lead's Email Domain to all Primary Email Domain Account field values to find a match and then assign the Lead to the Account Owner for conversion.

Please and Thanks!! 
Best Answer chosen by Stephanie Boggs 17
Alain CabonAlain Cabon
David Litton solved complex problems with only flows and processes and explains everything in detail on his blog: 

https://salesforcesidekick.com/2015/12/21/match-leads-to-an-account-automatically-with-an-account-number/

Regards

All Answers

Alain CabonAlain Cabon
Hello Stephanie,

You need a VLOOKUP but that is impossible with a formula (excepted for validation rules and with a very limited use).
The "zero code" alternative for VLOOKUP are not only the Apex code.
You should consider Flows and Process Builder.

With some clics, you could get your result without writing a line of code

Sample Flow That Loops Through a Collection:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_designer_example_loop.htm

Start a Flow with a Process:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_distribute_system_process.htm

If you are not comfortable with the flows, a underused tool designed for administrators which can replace the apex triggers in many cases, there are many trailhead projects:

https://trailhead.salesforce.com/en/projects/flow_calculate/steps/flow_calculate_determine

There are the record lookup and the fast lookup
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_designer_elements_fast_lookup.htm 

You  just need a little help for creating the flow itself probably (the less intuitive part). The process (lightning process builder) will be the easy part (very intuitive). 

Regards
Stephanie Boggs 17Stephanie Boggs 17
Thanks! I will take a look at those.I am very familiar with process builder, but not so much with flows. I will look deeper into flows since they are easier than apex for me!
Alain CabonAlain Cabon
Step by step:   https://www.xgeek.net/salesforce/save-approver-automatically-in-approval-processes-with-process-builder-and-flows/

The champion of the "flows" is David Litton, a Visual Flow expert  (currently working as a Solutions Architect at Ad Victoriam Solutions) :
https://salesforcesidekick.com/flows-in-action/

He solved complex problem with only flows and processes.

Regards
Alain CabonAlain Cabon
David Litton solved complex problems with only flows and processes and explains everything in detail on his blog: 

https://salesforcesidekick.com/2015/12/21/match-leads-to-an-account-automatically-with-an-account-number/

Regards
This was selected as the best answer