+ Start a Discussion
satyamsatyam 

How to write a trigger to check the duplicate record based on field

Hi,

 

I have a requirement is that

 

I have a field name as 'Job Name' where i filles engineer in one record now if user again creating the record where job name is engineer then its should show error massage that one record with same job name is allready exist.

 

So any idea how i can write a trigger for this.

 

Thanks in Advance:))))

Anu Raj.ax1269Anu Raj.ax1269

write a trigger on before update and query the object with the condition.

 

this is hoe to send a message to a vf page.

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ' Your Message');
ApexPages.addMessage(myMsg);