A sales team at a software company is facing challenges with duplicate lead records in Salesforce, which impacts their productivity and lead management efficiency. The sales manager has asked the Salesforce development team to solve this problem by implementing a deduplication rule.
To implement this dedupe rule, the Salesforce team has decided to write an apex method that checks if an email address is present in a list of existing email addresses collected from leads. If the given email address is present, the method will remove all occurrences of the email from the list.
Complete the given apex method to find and remove all occurrences of the email from a list.
Instructions :
1. The method should accept a string input for the email and a list of strings for the existing email addresses.
2. Check if the given input email address is present in the list.
3. Remove all occurrences of the email found in step 2 and return the updated list.
Example:
//Assume inputEmail has hello@decodeforce.com
//And leadEmailList has hello@decodeforce.com, welcome@decodeforce.com, hello@decodeforce.com
List<String > dedupedEmails = dedupeLeadController.removeDuplicates(inputEmail, leadEmailList);
//Result
// dedupedEmails will contain only welcome@decodeforce.com
Hint:
Use apex list methods to find and remove the duplicates from a list.
Click here to view all apex list practice examples