In this beloow i showed you custom Lead conversion .
Here I have taken a custom object Students,
In that i have created one custom button called convert.
If we click on the convert the account,contact and opportunity should create.
First we need to Create on global class and the method you intend to call from the javascript must be a Webservice Method.
Apex Class:
Here I have taken a custom object Students,
In that i have created one custom button called convert.
If we click on the convert the account,contact and opportunity should create.
First we need to Create on global class and the method you intend to call from the javascript must be a Webservice Method.
Apex Class:
global class customLead
{
public Students__c objStudents{get;set;}
webservice static void coversion(string student)
{
Students__c objStudents=new Students__c();
objStudents=[SELECT ID,Name FROM Students__c WHERE id=:student];
Account objAcc=new Account();
objAcc.Name=objStudents.Name;
Insert objAcc;
contact Objcon=new contact();
Objcon.Lastname=objStudents.Name;
Insert Objcon;
Opportunity objOpp= new Opportunity();
objOpp.Name=objStudents.Name;
objOpp.StageName='Active';
objOpp.CloseDate=System.Today();
Insert objOpp;
}
}Goto -->Setup-->Objects-->Students--->Buttons,links and Actions section
Click new Button or link.
Enter the Name of the button
Behaviour: Execute Javascript
Content Source :On-Click Javascript
Java Script Code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var result =sforce.apex.execute("customLead","coversion",{student:"{!Students__c.Id}"});
alert("result ");
window.location.reload();



I really enjoyed while reading your article and it is good to know the latest updates. Do post more. Please also read my topics about
ReplyDeleteSalesforce Customization Services
Salesforce Managed Services
Salesforce Managed Services USA
Hire Salesforce Consultant
Hire Salesforce Developers
AI Integration Services
AI Chatbot Development Services
n8n Development Services
Salesforce Application Development Services
Offshore Salesforce Development Services