Welcome to my blog

I have been working with Salesforce for quite a while, so don’t hesitate to contact me if you have any questions or want some advice.

s f

Subscribe
Follow Us
h

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

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

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());

Post a Comment