You need to sign in to do that
Don't have an account?

Duplicate Value Alert - Prompt User to continue
I would like to customize the following trigger to PROMPT the user when a duplicate value is found and ask if he wants to continue. If he clicks yes, then it should save the value
trigger ContactDuplicateTrigger on Contact (before insert) { for (Contact c : Trigger.new){ Contact[] contacts= [select id from Contact where Email = :c.Email]; if (contacts.size() > 0) { c.LastName.addError('Contact cannot be created - Contact already exists'); } }}
Triggers don't allow interaction with the UI.
You basically have 2 options that I am aware of:
One, create a "Is duplicate" checkbox on the contact record, if the user doesn't have it checked, and the record is a duplicate, generate an error indicating it is a duplicate and if they want to proceed, they need to check the box and save again. To prevent possible bad behavior, you could also generate an error if they check the box and it isn't a duplicate (my users would just check it every time if they thought that would be easier).
Two, you would have to create a VF page to replace the contact record, with a custom controller, and a custom save method. Then you could do the additional items to prompt the user.
All Answers
Triggers don't allow interaction with the UI.
You basically have 2 options that I am aware of:
One, create a "Is duplicate" checkbox on the contact record, if the user doesn't have it checked, and the record is a duplicate, generate an error indicating it is a duplicate and if they want to proceed, they need to check the box and save again. To prevent possible bad behavior, you could also generate an error if they check the box and it isn't a duplicate (my users would just check it every time if they thought that would be easier).
Two, you would have to create a VF page to replace the contact record, with a custom controller, and a custom save method. Then you could do the additional items to prompt the user.
Is there no possiblity to incorporate JavaScript into the APEX triggers?
I'd hate to have to 'outsource' my contact interface to Visualforce - it will make the maintenance a nightmare :)