// Code is for Custom lead conversion through custom lead convert button in Account,Contact,Opportunity
{!REQUIRESCRIPT("/soap/ajax/
{!REQUIRESCRIPT("/soap/ajax/
var accnt = new sforce.SObject("Account");
var insertedaccountid ="";
if({!Enquiry__c.Lead_
{
alert('Lead is already converted');
}
else
{
accnt.Name='{!Enquiry__c.
if(accnt.Name !="")
{
var p = new sforce.SObject('Enquiry__c');
p.id = "{!Enquiry__c.Id}";
p.Lead_Converted__c = 1;
// p.Enquiry_Status__c = 'Converted';
var result = sforce.connection.update([p]);
accnt.Id = '{!Account.Id}';
accnt.Name = '{!Enquiry__c.Company_Name__c}
accnt.OwnerId='{!Enquiry__c.
accnt.BillingStreet='{!
accnt.BillingCity='{!Enquiry__
accnt.BillingPostalCode='{!
accnt.BillingState='{!Enquiry_
accnt.BillingCountry='{!
var result2 = sforce.connection.create([
//alert(result2[0].id);
insertedaccountid= result2[0].id;
var cnt= new sforce.SObject("Contact");
cnt.Id = '{!Contact.Id}';
cnt.OwnerId='{!Enquiry__c.
cnt.AccountId=result2[0].id;
cnt.lastName = '{!Enquiry__c.Name}';
cnt.MailingStreet=accnt.
cnt.MailingCity=accnt.
cnt.MailingPostalCode=accnt.
cnt.MailingState=accnt.
cnt.MailingCountry=accnt.
var result = sforce.connection.create([cnt]
var opt= new sforce.SObject("Opportunity__
var suffixToAdd = "-CRM Implimentation";
opt.Id = '{!Opportunity__c.Id}';
opt.OwnerId='{!Enquiry__c.
opt.Account__c= cnt.AccountId;
opt.Name = '{!Enquiry__c.Company_Name__c}
var result = sforce.connection.create([opt]
if(result[0].getBoolean("
{
var urlis ="/"+insertedaccountid;
//alert(urlis);
window.location = urlis;
}
else
{
alert('Error : '+result);
}
}
}