Duplicate Prevention in VisualForce

Last published at: 2021-12-20 20:27:32 UTC

Duplicate Check's Duplicate Prevention in custom VisualForce pages is only available in the Advanced edition and up.

Apex code

Just add the following lines just before you execute the Insert or Update statement in your Apex Extension class.

    dupcheck.dc3Api api = new dupcheck.dc3Api();
ApexPages.Message prevention = api.doDuplicatePrevention(**ObjectData**);
if (prevention != null) {
   return null;

Replace the **ObjectData** with the object you are adding or updating.


  • You need to have the Advanced Edition of Duplicate Check for Salesforce.
  • You have to use an extension class in your custom visualforce page.
  • You need to use the following code in your VisualForce page to display the Duplicate Warning message:
< apex:pagemessages escape="false"/ >