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
Lavanya Ponniah 3Lavanya Ponniah 3 

How to prevent duplicate using validation rule?

I have Service Order as custom object.In this i have start date as date field,service start time as date time field, and Attended by as Lookup of Technician object Name.Now my question is if start date,service start time and Attended by are same for the other record it have show error  message as duplication
Sai Ram ASai Ram A
Hi Lavanya

You can Achieve this by creating New text Field and a WorkFlow, follow below Steps
Step1: Create a Text Field(Unique_Identifier__c) and set it as Unique Case Insensitive
Step2: Create a Workflow with your required Criteria. (Lets Say Attendend__c!= null)
Step3: Create a Workflow Field to Update (Unique_Identifier__c) with Attendend__c +TEXT(ServiceStartTime__c)+TEXT(StartDate__c) in formula Editor
or You can alos go for a Trigger, but recommend to use Standard provided features :)

Please mark my response as “Best Answer”, if you feel so inclined.

Thank you
BLearn
Jakson MonteiroJakson Monteiro
Hi there,

I feel this can be achieved by a trigger.

Trigger dupsServiceOrder on Service_Order__c(before insert)
{
List <Service_order__C> so= new List <Service_order__c>[select id,start_date__c,start_time__c,attended__c from service_order__c];
for(Service_Order__c s: so)
{
//if conditions
}

}