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
Ron WildRon Wild 

Supporting Person Accounts in a managed package

Is there any way to support person accounts in a managed package without making Person Account features a pre-requisite for installing the package?

 

I'd like to provide the option to create person-account instead of contacts in an Apex class that auto creates contacts after a certain event for those users  who have person-accounts enabled.   However, I don't want to have to require package users to install person-accounts.

 

Thanks,

Best Answer chosen by Admin (Salesforce Developers) 
JoeZaloom.ax395JoeZaloom.ax395

Hi,

 

I had the same problem while developing a managed package for a Salesforce integration. The approach I took was to put all the Person Account specific stuff in a separate class, and use dynamic sql to query Person Accounts. Without the dynamic sql the classes won't compile if they reference a Person Account field, I.E. PersonContactID. I expose a static method indicating whether Person Accounts are enabled or not and use that method when I need to branch for Person Accounts.

 

HTH,

joezaloom

All Answers

AtnMAtnM

I too would like this capability,

 

Scott

JoeZaloom.ax395JoeZaloom.ax395

Hi,

 

I had the same problem while developing a managed package for a Salesforce integration. The approach I took was to put all the Person Account specific stuff in a separate class, and use dynamic sql to query Person Accounts. Without the dynamic sql the classes won't compile if they reference a Person Account field, I.E. PersonContactID. I expose a static method indicating whether Person Accounts are enabled or not and use that method when I need to branch for Person Accounts.

 

HTH,

joezaloom

This was selected as the best answer
sebascansecosebascanseco
Hi Joe could you be more specific on your approach? Im in the same situation here and what I did so far was to add custom fields to Account like birthdate, firstName, LastName, etc.Then I created a recordtype named Individual and its respective page layout.

Now when a user needs to create an account refering to a person, he selects Individual from recordtype.

The advantages of this approach are:
1) easy and quick to implement
2) is packageable

The disadvantages:
1) user has to enter Name, First Name, Last Name and then apex concatenates LastName + ' ' + FirstName into Name. At first is weird to enter something in Name and then again in First and Last Name.
2) Can't handle this individual accounts as contacts, for instance in a birthday listview I need to implement a workaround
JarrettKuljisJarrettKuljis

It took us a bit to figure out.  Ultimately we chose to use record types and triggers to determine if the record (Contact) was a B2C Record or a B2B type.  If it was B2C we married the data via trigger to an account and overwrote the account view page with VF to force a lookup and redirect based on if the Account was a B2C pushing the user to the Contact Record.

 

Hope that helps.

sebascansecosebascanseco
Jarret if I understand correctly the user needs to create Contact first and then the Account or did I misunderstood the aproach?