'Need to enter records through a visualforce page into a custom object, but before inserting the record it should verify if similar record is present
I have a situation where I have a Class, a controller class, a visualforce page and a custom object. I need to insert the record into the custom object through visualforce page. But before inserting the record. the code should verify that a record with similar entries is not already present in the custom object and if it finds the record, then it should fetch that record instead of inserting new one and show it onto the visualforce page. Please guide me!
Solution 1:[1]
How do you define unique/similar for this object, do you have a text field marked as unique? Combination of LastName + Account.Name for example? Do you want to query the similar records yourself or is it something that admin should be capable of changing? Have you heard about Salesforce duplicate rules? Because once they're configured you can call them from Apex with findDuplicates
Post some code, what have you tried, what are you stuck with.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | eyescream |
