Create a javascript button and call controller(apex class) using sforce method as describe in above link.Create a method in class that will take lead id as parameter and will convert that lead into accounts and contacts. Call that method from script. Please take help of above link.
Create a javascript button and call controller(apex class) using sforce method as describe in above link.Create a method in class that will take lead id as parameter and will convert that lead into accounts and contacts. Call that method from script. Please take help of above link.
Hello Shweta, Thanks for your revert. Please help me what I am doing wrong here as when i click on the button depending upon the Status picklist value it's not creating the account and contact record.
global class ConvertLeadCustomClass
{
webservice static void method1(ID tid)
{
List<Account> accList=new List<Account>();
List<Contact> conList=new List<Contact>();
Map<id,id> projmap=new Map<id,id>();
for(Custom_Lead__c lead:[select Stage__c from Custom_Lead__c where Custom_Lead__c.Id=:tid])
{
if(lead.Stage__c=='Closed Converted')
{
Account a= new Account();
a.Name='ConvertedLeadAccount';
accList.add(a);
Contact c=new Contact();
c.LastName=a.Name;
c.AccountID=a.Id;
}
}
if((conList.size()>0)&&(accList.size()>0))
{
insert accList;
insert conList;
}
}
}
Buttons code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
a = sforce.apex.execute("ConvertLeadCustomClass","method1",{tid:"{!Custom_Lead__c.Id}"});
if(a == "It has been converted Successfully"){
alert(a);
}
else{
location.reload();
}
Sorry the Javascript button will be : {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} a = sforce.apex.execute("ConvertLeadCustomClass","method1",{tid:"{!Custom_Lead__c.Id}"});
if(a!=null) { a="It has been successfully Converted"; alert(a); }
else{ location.reload();
}
It's creating Account but not Contact..I have no idea why
You can take help of below link to create a custom button on custom object :
http://www.mstsolutions.com/blog/content/creating-custom-button-javascript-salesforce
Create a javascript button and call controller(apex class) using sforce method as describe in above link.Create a method in class that will take lead id as parameter and will convert that lead into accounts and contacts. Call that method from script. Please take help of above link.
Thanks
Shweta
All Answers
You can take help of below link to create a custom button on custom object :
http://www.mstsolutions.com/blog/content/creating-custom-button-javascript-salesforce
Create a javascript button and call controller(apex class) using sforce method as describe in above link.Create a method in class that will take lead id as parameter and will convert that lead into accounts and contacts. Call that method from script. Please take help of above link.
Thanks
Shweta
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
a = sforce.apex.execute("ConvertLeadCustomClass","method1",{tid:"{!Custom_Lead__c.Id}"});
if(a!=null)
{
a="It has been successfully Converted";
alert(a);
}
else{
location.reload();
}
It's creating Account but not Contact..I have no idea why
Your problem has been solved ? or still you are getting some problem ?