You need to sign in to do that
Don't have an account?

Trouble with Lead Conversion
I wrote and s-control to convert a number of leads from a leads view. It works fine as long as I want duplicate accounts created.
I check to see if the account exists and if so get the ID. I can displaye the ID using an alert so I know I got it and it is correct. I put the Id into convert.accountId yet when I call leadConvert the accountId is null.
I have added the code in case I am making a stupid mistake. I changed the Status to something that is invalid so I get an error that shows me what is being passed. The leadId is passed correctly but not the accountId. Thanks for any help.
var convert = new sforce.LeadConvert();
convert.leadId = records[i].Id;
convert.leadId = records[i].Id;
//Now check if account already exists and if it does also check if contact exists
//alert("SELECT ID from Account WHERE Account.Name='" + records[i].Company + "'");
var account = sforce.connection.query("SELECT ID from Account WHERE Account.Name='" + records[i].Company + "'");
//alert("SELECT ID from Account WHERE Account.Name='" + records[i].Company + "'");
var account = sforce.connection.query("SELECT ID from Account WHERE Account.Name='" + records[i].Company + "'");
if (account.size > 0)
{
var accrec = account.getArray('records');
convert.accountId = accrec[0].Id;
alert("Acct ID: "+ convert.accountId + " and Lead Id "+ convert.leadId);
{
var accrec = account.getArray('records');
convert.accountId = accrec[0].Id;
alert("Acct ID: "+ convert.accountId + " and Lead Id "+ convert.leadId);
var contact = sforce.connection.query("SELECT ID from Contact WHERE Contact.Name='" + records[i].Name + "'");
if (contact.size > 0)
{
var contrec=contact.getArray('records');
convert.contactId=contrec[0].Id;
}
}
if (contact.size > 0)
{
var contrec=contact.getArray('records');
convert.contactId=contrec[0].Id;
}
}
convert.convertedStatus = "AClosed - Converted";
convert.doNotCreateOpportunity="true";
convert.doNotCreateOpportunity="true";
var saveResult = sforce.connection.convertLead([convert]);
I think you are missing some required app field value. Just check passing query through firebug.