3 answers
Hi Satish,Instead of Fetching all the records and doing the business logic in all the records, Please add the business logic in your SOQL itself so that it retreives only if any relevant record is available. Something similar to the below.
SELECT Id, firstName, lastName,phone, email FROM Contact WHERE firstName = oldFirstFame AND lastName = oldFirstFame AND email = oldEmail LIMIT 49000
If you replace yout existing query with this, all you need to do is a if contition and if a record is available as an output of the query, you just need to mark the error.
This is just for the basic duplicate check you have asked for.If you need to add more funtionality the solution might differ.Alternatively you could use SOSL as well based on the business logic needed.Let me know if that helps.As a common practice, if your question is answered, please choose 1 best answer.Additionally you can give every answer a like if that answer is helpful to you.Regards,Anto NirmalThanks Anto, that was indeed helpful!!!