+ Start a Discussion
AbanteAbante 

Lead conversion unavailable

Hello everyone,

 

Is there any way to let a user convert leads only if he is the owner?

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

                                                          

           You can handle this through some custom error message in trigger in case the user editing is the owner, then you can convert the leads otherwise it restrict your operation.

                                  

                                                                trigger trigMapFieldsdata on Lead (before update)

                                                                {

                                                                for(Lead lead:System.Trigger.new)

                                                                {

                                                                if (lead.IsConverted){// Your business logic here..

                                                                }

                                                                }


All Answers

Ispita_NavatarIspita_Navatar

Hi Abante,

Conversion of a lead leads to creation of :-

  • an account
  • an opportunity
  • a contact
  • a task 

Hence you can put a trigger on the creation of these objects which will raise a if the user converting is not the owner.

Alternatively you can have a custom button of your own on which you can fire validation using javascript API to check if the user converting is the owner if yes redirect user to the following url:-

"https://ap1.salesforce.com/lead/leadconvert.jsp?retURL=%2F"+ LeadId + "&id=" +LeadId

else you can alert the user with appropriate message.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

AbanteAbante

Thanks a lot Ispita,

 

Just one more thing, Do you have the code of the trigger you mention?

 

Thanks again!!

Ispita_NavatarIspita_Navatar

                                                          

           You can handle this through some custom error message in trigger in case the user editing is the owner, then you can convert the leads otherwise it restrict your operation.

                                  

                                                                trigger trigMapFieldsdata on Lead (before update)

                                                                {

                                                                for(Lead lead:System.Trigger.new)

                                                                {

                                                                if (lead.IsConverted){// Your business logic here..

                                                                }

                                                                }


This was selected as the best answer
AbanteAbante

Thank you Ispita, It worked perfectly:

 

trigger leadPreventer on Lead (before insert, before update)

{

if(trigger.isUpdate)

{

for(Lead lead:System.Trigger.new)       

{       

if (lead.IsConverted && UserInfo.getUserId()!=lead.OwnerId)       

{           

lead.addError(' It's not possible');

}       

}

}

}

Ispita_NavatarIspita_Navatar

You are most welcome.