function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
scottj2scottj2 

Confusing description in ConvertLead description

We are building a custom lead convert page, and am utilizing the apex ConvertLead operation.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm

 

One of the features we are giving our users is the ability to not only choose an account to merge the lead to, but also give the option to either create a new contact, or merge to an existing contact..

 

Here is the description from that page that I am confused with:

 

setContactId

Sets the ID of the contact into which the lead will be merged (this contact must be associated with the account specified with setAccountId, and setAccountId must be specified). This value is required only when updating an existing contact.

Important

If setContactID is specified, then the application creates a new contact that is implicitly associated with the account. 

 

The first sentence makes sense.  But the second does not...if you want to create a new contact, you can't possibly set the contact id, since it doesn't exist yet.  Should this read:

 

If setContactID is not specified, then the application creates a new contact that is implicitly associated with the account. 

craigmhcraigmh

There are 3370 page of documentation. This isn't the first issue (search for "bappl"), and it probably won't be the last. I'd just suggestion playing around with it to see how the functionality truly works.

 

http://www.tehnrd.com/how-to-be-successful-with-salesforce/

scottj2scottj2

Haha....nice, gotta love it.

 

Unfortunately, I tried it both ways...neither of which did what I wanted it to do.

 

I can't seem to get the convertLead function to create a contact on an existing account no matter what I set the contactId to.

craigmhcraigmh

That doesn't surprise me. I'm not a fan of the convertLead function. That's why I normally just use triggers.

trigger LeadUpdated on Lead (after update) {
	for(integer i = 0; i < trigger.new.size(); i++) {
		if(!trigger.old[i].IsConverted && trigger.new[i].IsConverted) {
			//do stuff
		}
	}
}