+ Start a Discussion
Trevor ViallTrevor Viall 

compare new record with all current records

I'm sure this is a very simple problem, but I'm still fairly new to saleforce and can't seem to find the solution. So I'm trying to compair new records when inserted with all existing records to ensure that the last name values are unique otherwise it won't post the new record. I'm sure that I will have to put this in a before insert trigger but I can seem to figure out how exactly to run the compairson. 
Best Answer chosen by Trevor Viall
Andrew GAndrew G
I would investigate Duplicate Management in Salesforce.
a quick link to help discover the basics
https://trailhead.salesforce.com/en/content/learn/modules/sales_admin_duplicate_management

Regards
Andrew

All Answers

Andrew GAndrew G
I would investigate Duplicate Management in Salesforce.
a quick link to help discover the basics
https://trailhead.salesforce.com/en/content/learn/modules/sales_admin_duplicate_management

Regards
Andrew
This was selected as the best answer
SUCHARITA MONDALSUCHARITA MONDAL

Hi Trevor,

As @Andrew mentioned, this can be resolved with duplicate rules. It's always a best practice to go with Decalarative/Out of the box functionalites rather than going into code. As when you code you have to maintain that also, test classes, coverage etc. needs to be taken care of.

Best would be go with decalarative first and if you don't find desire solution then go with customization.

Hope this helps

Thanks,
Sucharita