You need to sign in to do that
Don't have an account?
Hemalatha Paruchuri
Custom object(like lead) convert button like account and contact
Hi,
I have a custom object like objectA(like lead) i need to conver lead account and contact using button ..how it is possible
I have a custom object like objectA(like lead) i need to conver lead account and contact using button ..how it is possible
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var accnt = new sforce.SObject("Account");
var recType=sforce.connection.query("SELECT name, id FROM RecordType" );
//alert(recType);
var records = recType.getArray("records");
//alert(records);
accnt.Name='{!My_Leads__c.Company__c}';
if(accnt.Name !="")
{
accnt.RecordTypeId = records[0].Id;
//alert(records[0].Id);
accnt.Id = '{!Account.Id}';
accnt.Name = prompt('','{!My_Leads__c.Company__c}');
accnt.OwnerId='{!My_Leads__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
var cnt= new sforce.SObject("Contact");
cnt.Id = '{!Contact.Id}';
cnt.OwnerId='{!My_Leads__c.OwnerId}';
cnt.AccountId=result[0].id;
cnt.lastName = prompt('','{!My_Leads__c.Lead_Name__c}');
var result = sforce.connection.create([cnt]);
if(result[0].getBoolean("success"))
{
alert('contact created successfully');
window.location.reload();
}
else{
alert('Error : '+result);
}
}
else
{
accnt.RecordTypeId=records[1].Id;
//alert(records[1].Id);
accnt.Id = '{!Account.Id}';
accnt.LastName = prompt('','{!My_Leads__c.Lead_Name__c}');
accnt.OwnerId='{!My_Leads__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
else
{
alert('Error : '+result);
}
}
All Answers
This can be acheieved using VF Page. Below are the steps that you need to follow.
1. Create a VF Page with Standard Controller as the custom Object.
2. In the VF Page allow user to select which records to create.(As a check box)
3. In convert button write a logic to create the respective object.
first create account,
then, contact and relate it with account created.
Let me know if you need any help on this. If this really solves your porblem mark it as answer.
Thanks
Manoj S
i need to develope one button in custom object (like lead object) when click on button create account and contact
That is the first step to do the converstion proces. VF Page depends on the complexity that you have. It can also be achieved using Javascript Button.
Thanks
Manoj S
Below are the steps
1. StandardController should be your custom object.
2. Add an extenstion.
3. Display 3 Checkboxes in the page with (Create Account, Create Contact and Create Task)
4. Add a button in the page (Let Say Convert)
5. Write a controller method which will get the id of the custom object from the url.
6. Query the required field needed to create a account and contact from the Custom Object
7. Insert the record into salesforce.
Let me know if you know more details to do this.
Thanks
Manoj S
Thanks
Manoj S
I need javascript button..i dont want visuforce page
http://www.jitendrazaa.com/blog/salesforce/create-and-update-records-using-javascript-button-in-salesforce-ajax-toolkit/
http://salesforce.stackexchange.com/questions/79533/salesforce-custom-button-onclick-javascript-create-multiple-child-record
Thanks
Manoj S
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var accnt = new sforce.SObject("Account");
var recType=sforce.connection.query("SELECT name, id FROM RecordType" );
//alert(recType);
var records = recType.getArray("records");
//alert(records);
accnt.Name='{!My_Leads__c.Company__c}';
if(accnt.Name !="")
{
accnt.RecordTypeId = records[0].Id;
//alert(records[0].Id);
accnt.Id = '{!Account.Id}';
accnt.Name = prompt('','{!My_Leads__c.Company__c}');
accnt.OwnerId='{!My_Leads__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
var cnt= new sforce.SObject("Contact");
cnt.Id = '{!Contact.Id}';
cnt.OwnerId='{!My_Leads__c.OwnerId}';
cnt.AccountId=result[0].id;
cnt.lastName = prompt('','{!My_Leads__c.Lead_Name__c}');
var result = sforce.connection.create([cnt]);
if(result[0].getBoolean("success"))
{
alert('contact created successfully');
window.location.reload();
}
else{
alert('Error : '+result);
}
}
else
{
accnt.RecordTypeId=records[1].Id;
//alert(records[1].Id);
accnt.Id = '{!Account.Id}';
accnt.LastName = prompt('','{!My_Leads__c.Lead_Name__c}');
accnt.OwnerId='{!My_Leads__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
else
{
alert('Error : '+result);
}
}
i want to convert custom object into account, contact and opportunity ? cloud u please provide complete code once.