Salesforce · Spring 21

SPRING 21 – PERSON ACCOUNT AND A BUSINESS ACCOUNT AT THE SAME TIME WITH NEW LEAD CONVERT METHODS

For Salesforce orgs that use APEX Lead Convert, Person Accounts, and Contacts to Multiple Accounts, new methods are available on the LeadConvert() class. These methods allow converting leads into a business account and a person account instead of a contact.

Note: This change applies to Lightning Experience in Enterprise, Performance, and Unlimited editions.

getRelatedPersonAccountId():

  • Gets the ID of an existing person account to convert the lead into, in addition to the business account.

setRelatedPersonAccountId(relatedPersonAccountId):

  • Sets the ID of the existing person account to convert the lead into, in addition to the business account.

getRelatedPersonAccountRecord():

  • Gets the entity record of a new person account to convert the lead into, in addition to the business account.

setRelatedPersonAccountRecord(Entity relatedPersonAccountRecord):

  • Sets the entity record of a new account to convert the lead into, in addition to the business account.

To set the related person account, use either setRelatedPersonAccountId to specify an existing ID or setRelatedPersonAccountRecord to specify a new record, but not both. The person account appears in the Related Contacts list on the business account’s record home page.

A new method is available in the LeadConvertResult class.getRelatedPersonAccountIdThe ID of the new or existing related person account specified when convertLead() was invoked.

Example:

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(leadId);
lc.setAccountId(existingBusinessAccountId);
lc.setRelatedPersonAccountId(existingRelatedPersonAccountID);
lc.setOpportunityId(existingOpportnityId);
lc.setSendNotificationEmail(true);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
 
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s