function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Moman192000Moman192000 

Validation Rule to dissallow duplicates(exact match) at point of entry in one field only

I have a very basic custom object in which I need to prevent duplicates(exact match).  I cannot just use a "unique" value though, because in certain circumstances duplicates should be allowed.  What I want to do is create a validation rule where if an "override" box is checked the rule will allow duplicates, but otherwise it won't.  Can someone please help me with the code?
 
Initially I tried:
 
REGEX ( field , field)  The only problem is that it checks itself and thinks every entry is a duplicate.
 
Please help!
RickyGRickyG
Since you want to check a value in the existing record against all other records in the object, you will have to use an Apex trigger to implement this type of validation.  Of course, with Apex you can easily implement any logical condition you want to apply to the check.

Hope this helps.
Moman192000Moman192000

Thank you for your feedback.  It does not give me an option to add a new trigger.  I see where triggers are, but cannot create a new one, and I do have APEX Author permission.  Am I missing something?

Thanks again!

Matt

CliffACliffA
You can't create a trigger on a production account via the browser interface.  You must create it offline and publish it an API. 

Search for the Eclipse IDE and the Force.com plugin - using these tools you'll be able to create the trigger offline and publish it to your site.
Moman192000Moman192000
Great Thanks!
KC-CRM AnalystKC-CRM Analyst

These triggers can also be created in your salesforce.com sandbox account.  If you do not currently have a salesforce.com sandbox, you can create it by following the clickpath:  Setup | Data Management | Sandbox

If there is no sandbox option, it may need to be enabled for your account.  Contact your Account Executive or Salesforce Support to have this enabled.

Moman192000Moman192000
I'd like to hire a developer to create this feature for me.
 
Please send me your contact info, @ morlando@arcadianhealth.com , if you are interested
 
Thanks
Moman192000Moman192000
Would you be interested in developing this feature for me?
RickyGRickyG
You also might want to check out the operation of the VLOOKUP function for validations.  Your challenge would still be to come up with a definition of what defined a 'duplicate' record.  Once you came up with these logical criteria, you could create a formula field with the unique identifier and use the VLOOKUP against that field.

Hope this helps.
rahuljrahulj
Ricky, trying to contact you on a domain you own...pls email me at giatinomoe@yahoo.com so that I have your email address, Tks!
Harsh DeveloperOrgHarsh DeveloperOrg
Hey, incase if someone is still struggling with this issue, you can simply go to setup and enter duplicate management in quick find box, there you will find duplicate rules and matching rules. You can create a custom matching rule if you want or else simply go with standard matching rule, then in duplicate rules you can choose the matching rule and set action which you would like when a pottential duplicate is found.
For more info visit here- https://trailhead.salesforce.com/content/learn/modules/sales_admin_duplicate_management/sales_admin_duplicate_management_unit_2?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-administrator-credential 

Thanks,
Harsh