You need to sign in to do that
Don't have an account?

I need an Apex Trigger to update the Lead Owner
I need an Apex Trigger that will update and move a lead from our Content Syndication queue to the reassignment queue when a lead reaches >80%. I cannot use a workflow, because that will only kick off on creation or edit, and the lead scoring tabulates by Einstein every hour. Unless I do a mass update to edit/save and kick off the workflow, Salesforce help has said that an Apex Trigger is the only solution.
I have this code, but I get an error on line 5: Error: Compile Error: Missing '<EOF>' at 'for' at line 5 column 5
trigger LeadRoutingTrigger on Lead (before update) {
Group ReassignmentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Reassignment Queue' LIMIT 1];
Group ContentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Content Syndication and Events Queue' LIMIT 1];
}
for(Lead currentLead : Trigger.new) {
if(currentLead.OwnerId == ContentQueue.Id
&& currentLead.Lead_Insights_Value__c > 80) {
currentLead.OwnerId = ReassignmentQueue.Id;
}
}
}
Does anyone have a suggestion?
Thanks
I have this code, but I get an error on line 5: Error: Compile Error: Missing '<EOF>' at 'for' at line 5 column 5
trigger LeadRoutingTrigger on Lead (before update) {
Group ReassignmentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Reassignment Queue' LIMIT 1];
Group ContentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Content Syndication and Events Queue' LIMIT 1];
}
for(Lead currentLead : Trigger.new) {
if(currentLead.OwnerId == ContentQueue.Id
&& currentLead.Lead_Insights_Value__c > 80) {
currentLead.OwnerId = ReassignmentQueue.Id;
}
}
}
Does anyone have a suggestion?
Thanks
trigger LeadRoutingTrigger on Lead (before update) {
Group ReassignmentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Reassignment Queue' LIMIT 1];
Group ContentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Content Syndication and Events Queue' LIMIT 1];
List<Lead> updLeadLst = new List<Lead>();
for(Lead currentLead : Trigger.new) {
if(currentLead.OwnerId == ContentQueue.Id
&& currentLead.ankalex__Lead_Insights_Value__c > 80) {
currentLead.OwnerId = ReassignmentQueue.Id;
updLeadLst.add(currentLead);
}
}
if(updLeadLst.size() >0){
Database.update(updLeadLst,false);
}
}
please mark this as answred in case the solution is working for you.
Thanks
Check the following code.
--
Thanks,
Prashant
public class LeadRoutingTrigger
{
public static testmethod istest
LeadGroup=Queue;
LeadWhoid=00G00000006skVdEAI;
Lead.Lead_insights_Value__c>'80';
insert currentLead.WhoId='00G00000006t3ZFEAY';
}
The error I get is: Error: Compile Error: Unexpected token '='. at line 6 column 10
You may try something like this..
--
Thanks,
Prashant
The Lead_insight_Value__c is not in the User object, but the Leads object, so it is erroring out...
Shauna
Lead l = new Lead(LastName='dummylastname', Lead_insight_Value__c=85,OwnerId = ContentQueue.Id, Company = 'Dummy Company', LeadSource='test');
--
Thanks,
Prashant
I hope the above solution worked for you...Please code this thread by marking the best answer.
--
Thanks,
Prashant