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
sunny_mhl10@yahoo.comsunny_mhl10@yahoo.com 

Duplicate Check

Hi

 

   We have created Web-To Lead form . We want it should check that name does not exists in Accounts then it should save the record else it should give message that name already exists.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,


You have to write a trigger on Lead which will check before inserting the lead from web to lead.
Trigger DuplicateLead on Lead(before insert)
{
List<Account> ac=[select id,name from account where name=trigger.new[0].lastname];
If(ac.size() > 0)
{
// Use adderror method to display the error that you want to display.
}
}

All Answers

Navatar_DbSupNavatar_DbSup

Hi,


You have to write a trigger on Lead which will check before inserting the lead from web to lead.
Trigger DuplicateLead on Lead(before insert)
{
List<Account> ac=[select id,name from account where name=trigger.new[0].lastname];
If(ac.size() > 0)
{
// Use adderror method to display the error that you want to display.
}
}

This was selected as the best answer
sunny_mhl10@yahoo.comsunny_mhl10@yahoo.com

Hi

 

  It is giving me error on line 3

 

unexpected token: 'trigger.new' at line 3 column 57

 

Thanx

 
sunny_mhl10@yahoo.comsunny_mhl10@yahoo.com

Hi

 

  It is resolved.

 

Thanx