You need to sign in to do that
Don't have an account?
tdep
Input to a field with Unique (Dupe checking) enabled
Hi,
I currently have a small form that a user can input 4 fields for a new entry into the database. Everything works fine when I remove the "Unique" check for dupes on the Email field. But if I have it enabled, it jumps to the auth required screen.
As you can see below, the class is very simple and functions properly if a user inputs a new entry that does not exist. How can I check against unique at the insert? Or should I be doing a field validation rule? Not sure which is the best path to take.
public class addbrokerclass { public Broker_Contact__c newBroker { get; set; } public addbrokerclass() { newBroker = new Broker_Contact__c(); } public PageReference add() { insert newBroker; return new PageReference('/survey/landing'); } }
Thanks in advance!
This might work:
It checks for whether the system has been able to insert the record, and if it is not able (e.g. because it is a duplicate) it will stay on the same page instead of trying to move you on.
Try putting this somewhere on your visualforce page as well. It should show you the error message
All Answers
This might work:
It checks for whether the system has been able to insert the record, and if it is not able (e.g. because it is a duplicate) it will stay on the same page instead of trying to move you on.
Try putting this somewhere on your visualforce page as well. It should show you the error message
A catch ended up working.
To demo it, I had to remove the Unique on Email :)