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
Mike ChaputMike Chaput 

Assign Leads

I need assistance with a trigger or Apex (i think it's Apex).

When a new lead comes in:

1) If the lead has a company name, check for that company in Accounts
2) If found, assign the new lead to the account owner.

Thanks for any assistance.

Mike


sites1.3909952495827087E12sites1.3909952495827087E12
Hi Mike,

U have to write a piece of code to achieve this.Contact me vunnamsfdc@gmail.com for consulting.
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
Lets take Lead as one object and account as one object.
 
Try this code:
Trigger assignaccount on Lead(after insert){
For(Lead l: Trigger.new)
{
List <Account>a =[Select Account name from account];
If (a.contains(l))
{
 l.OwnerID = a.ACCOUNT.OwnerId;
  }
}
}
Just to give idea to you i typed this code.just take this and work on it for your requirement