+ Start a Discussion
Yamini BathulaYamini Bathula 

lightning action for javascript button for lead conversion

Hi Guys,

we are planning to move to lightning next month. We do have a couple of javascript buttons on the classic version at the moment. I am looking for an alternative to a javascript button for lead conversion. That button checks for some mandatory fields on leads before converting a lead and displays an alert window to fill the mandatory fields.

Would you guys please help me with a lightning alternative for this?

 
Yamini BathulaYamini Bathula
var erstring = "Please Enter Below Mandatory Fields before converting this Lead\n"; 
var hasError = false; 




if({!ISBLANK(Lead.ParentAccount__c)}) 
{ 

erstring += "Parent Account \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.FirstName)}) 
{ 
erstring += "First Name\n"; 
hasError = true; 
} 
if({!ISBLANK(Lead.Email)}) 
{ 
erstring += "Email \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Phone)}) 
{ 
erstring += "Phone Number \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Company)}) 
{ 
erstring += "Company \n" ; 
hasError = true; 
} 
if({!ISBLANK(TEXT(Lead.Country__c))}) 
{ 
erstring += "Country \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Industry_Ipay__c)}) 
{ 
erstring += "Industry \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Trading_Name__c)}) 
{ 
erstring += "Trading Name \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Street)}) 
{ 
erstring += "Street Address \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.State)}) 
{ 
erstring += "State \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.City)}) 
{ 
erstring += "City \n" ; 
hasError = true; 
} 

if({!ISBLANK(Lead.PostalCode)}) 
{ 
erstring += "Post Code \n" ; 
hasError = true; 
} 


if({!ISBLANK(Lead.Avg_Trans_Amount__c)}) 
{ 
erstring += "Average Transaction Amount \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Trans_Per_Month__c)}) 
{ 
erstring += "Transactions per month \n" ; 
hasError = true; 
} 

if({!ISBLANK(Lead.Max_Single_Pay_Amt__c)}) 
{ 
erstring += "Maximum single payment amount \n" ; 
hasError = true; 
} 
if({!ISBLANK(Lead.Director_Name__c)}) 
{ 
erstring += "Director Name \n" ; 
hasError = true; 
} 

if({!ISBLANK(Lead.Director_Email__c)}) 
{ 
erstring += "Director Email\n" ; 
hasError = true; 
} 

if(!({!Lead.Direct_Debit_Requested__c} || {!Lead.eCommerce__c} || {!Lead.Video_Payment__c} || {!Lead.Xero_Payment_Now__c} || {!Lead.Xero_Direct_Debit__c})) 
{ 
erstring += "One of the products Direct Debit Requested/Ecommerce/Video Payment/Xero Payment Now/Xero Direct Debit is not selected"; 
hasError = true; 

} 


 

if(hasError) 
{ 
alert(erstring); 
} 
else 
{ 
window.location.href = '/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}' ; 
}

 
James LoghryJames Loghry
Hi Yamini,

Take a look at creating a component (and lightning quick action) that utilizes the "lightning:input" component for your lead fields: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_input.htm

Not only, can you specifiy whether or not a field is required, but this component provides its own validation checking (you can even do stuff like validate phone numbers and email address through regex). If you need to do even more complex validation, you can use the lightning:input's validity attribute as well (an example of this is shown in that URL).
Yamini BathulaYamini Bathula
Thanks for the response James.

Sorry for the delay in my reply.

How can I redirect it to lead conversion page from Custom Component? Any idea how can this be achived?

Thanks,
Yamini.
Yuvika Aggarwal 16Yuvika Aggarwal 16
Hi Yamini, did you manage to find the solution for above. We have similar requirements where some fields are checked before converting Leda and we need to switch this to Lightning.
Thanks
Yuvika