You need to sign in to do that
Don't have an account?
Rahul
hello friends, I need to update the owner of the lead for a duplicate lead record, if Email address or mobile number matches the previous record, then owner of the second duplicate lead should be automatically the previous owner
Will it be achieved through Trigger, Need help
Thanks in Advance
Thanks in Advance
trigger UpdateOwnerID on Lead(before insert, before update) {
Set<string> aliasscope = new Set<String>();
for(Lead opp : trigger.new)
{
aliasscope.add(opp.Assigned_To__c);
}
map<string,id> userIdbyAlias = new map<string,id>(); //Keep in mind this will only store one user id per alias
for(User u : [Select id,Name from user where Name IN :aliasscope])
{
userIdbyAlias.put(u.Name,u.Id);
}
for (Lead objOpportunity : Trigger.new)
{
if (objOpportunity.OwnerId <> userIdByAlias.get(objOpportunity.Assigned_To__c) )
{
objOpportunity.OwnerId = userIdByAlias.get(objOpportunity.Assigned_To__c);
}
}
}