I am trying to create a validation formula in order to perform the below logic.
I_Priority__c
is a PicklistC_Start_Date__c
is a Date FieldC_End_Date__c
is a Date FieldThese field values cannot be duplicated in the database. Therefore every new entry to be inserted needs to be validated accordingly.
For this, I am using the below formula
NOT(EXISTS((SELECT Id FROM I_Coverage__c
WHERE I_Priority__c = {{I_Priority__c}}
AND C_Start_Date__c = {{C_Start_Date__c}}
AND C_End_Date__c = {{C_End_Date__c}})))
When I press the 'Check Syntax' button, I am getting
Error: Syntax error. Missing ')'
This is... very misguided. You can't run queries in formulas like that and where's that {{syntax}}
coming from. Are you a Marketing Cloud person or something?
I'll list some options but you have lots of reading to do.
If it was Account/Contact/Lead/Person account - you could use duplicate rules. You have a custom object so go upvote an idea: https://ideas.salesforce.com/s/idea/a0B8W00000GdZjcUAF/potential-duplicates-for-custom-objects, read the comments, maybe there's an app you can use.
You could look into VLOOKUP function - but it'd require the 3 values all appear in the Name field of the object which may be a no-go for you.
you could write an apex trigger or flow but properly protecting the scenario may be harder than you think.
undelete
So... is there an easy config solution? Yep.
Unique__c
Text, 255. Mark it Unique case insensitive.before insert, before update
trigger if you feel like it, populating the field with combination of your 3 fields. No conditions, can run always (low performance impact and before
means it's a save for free).