• Elly-BIG
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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;
//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 + "'");
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 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;
               }
  }
convert.convertedStatus = "AClosed - Converted";
convert.doNotCreateOpportunity="true";
var saveResult = sforce.connection.convertLead([convert]);
I have created a custom button which I use on the Contact Detail page. I am wondering if there is any way to show or hide the button based on the users security settings (profile)? Is this possible? I only want certain profile types to be able to use the button.
I couldn't find any security settings based around Custom Buttons.
Thanks for any help!
-Jeff
  • January 23, 2008
  • Like
  • 0