Is it possible to deploy Apex code which uses Person Accounts to an org which doesn't have Person Accounts enabled? The Next CEO of Stack Overflow2019 Community Moderator ElectionWhat's the best way to check if person accounts are enabled via Apex Code?Multiple currency in Managed package without breaking support for non-currency orgs?Managed package with optional support for Orgs with Revenue Schedules enabledDetermine via Apex if product schedules are enabled for an OrgCustom fields and triggers for optional features in a managed packageBest practices for using person accounts within a managed packageManaged Package - check for Person Accounts with post install scriptDeploy metadata from one org to another using apexHow to check if Person Accounts enabled in a formula field in a Managed Package?How can we include managed package code into a site template which is defined in customer org
What happened in Rome, when the western empire "fell"?
Is it a bad idea to plug the other end of ESD strap to wall ground?
Is Nisuin Biblical or Rabbinic?
DISTINCT column combination with permutations
Do scriptures give a method to recognize a truly self-realized person/jivanmukta?
Computationally populating tables with probability data
Compensation for working overtime and on Saturdays
Can I board the first leg of the flight without having final country's visa?
Is it okay to majorly distort historical facts while writing a fiction story?
The Ultimate Number Sequence Puzzle
Raspberry pi 3 B with Ubuntu 18.04 server arm64: what chip
Free fall ellipse or parabola?
How to pronounce fünf in 45
What will the new character ⿰令和 look like?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Does 단비 (sweet rain) have Hanja?
Button value to be changed back to original value on timeout (form double submit)
Can this note be analyzed as a non-chord tone?
Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne" ?
Is there a way to save my career from absolute disaster?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Won the lottery - how do I keep the money?
Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact
Players Circumventing the limitations of Wish
Is it possible to deploy Apex code which uses Person Accounts to an org which doesn't have Person Accounts enabled?
The Next CEO of Stack Overflow2019 Community Moderator ElectionWhat's the best way to check if person accounts are enabled via Apex Code?Multiple currency in Managed package without breaking support for non-currency orgs?Managed package with optional support for Orgs with Revenue Schedules enabledDetermine via Apex if product schedules are enabled for an OrgCustom fields and triggers for optional features in a managed packageBest practices for using person accounts within a managed packageManaged Package - check for Person Accounts with post install scriptDeploy metadata from one org to another using apexHow to check if Person Accounts enabled in a formula field in a Managed Package?How can we include managed package code into a site template which is defined in customer org
I want to create a managed package which supports orgs both with and without PersonAccounts enabled.
- Is it possible?
- How would I achieve this?
apex managed-package person-accounts
add a comment |
I want to create a managed package which supports orgs both with and without PersonAccounts enabled.
- Is it possible?
- How would I achieve this?
apex managed-package person-accounts
add a comment |
I want to create a managed package which supports orgs both with and without PersonAccounts enabled.
- Is it possible?
- How would I achieve this?
apex managed-package person-accounts
I want to create a managed package which supports orgs both with and without PersonAccounts enabled.
- Is it possible?
- How would I achieve this?
apex managed-package person-accounts
apex managed-package person-accounts
asked Mar 19 at 7:25
RobsRobs
2,344638
2,344638
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Is it possible?
Yes.
How would I achieve this?
You need to avoid using any "hard" references to any Person Account features. For example, you'll need to check if IsPersonType is a valid field:
Boolean isPersonAccountsEnabled = sObjectType.RecordType.fields.getMap().containsKey('IsPersonType');
Since this field is only present when you have Person Accounts enabled, you have to do dynamic queries to avoid making a hard link:
RecordType[] personTypes = Database.query('SELECT Id FROM RecordType WHERE IsPersonType = true');
And so on. You can read more about Dynamic Apex in the documentation.
Finally, and I cannot stress this enough, always check the package dependencies before uploading. If you upload a version that includes dependencies to Person Accounts, you will never be able to undo it (at least, it's very hard to undo and involves Partner Support).
You may want to put all your Person Account dependencies in to an Extension Package to avoid accidentally creating dependencies, but then you'd have to have customers install two separate packages.
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f254386%2fis-it-possible-to-deploy-apex-code-which-uses-person-accounts-to-an-org-which-do%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is it possible?
Yes.
How would I achieve this?
You need to avoid using any "hard" references to any Person Account features. For example, you'll need to check if IsPersonType is a valid field:
Boolean isPersonAccountsEnabled = sObjectType.RecordType.fields.getMap().containsKey('IsPersonType');
Since this field is only present when you have Person Accounts enabled, you have to do dynamic queries to avoid making a hard link:
RecordType[] personTypes = Database.query('SELECT Id FROM RecordType WHERE IsPersonType = true');
And so on. You can read more about Dynamic Apex in the documentation.
Finally, and I cannot stress this enough, always check the package dependencies before uploading. If you upload a version that includes dependencies to Person Accounts, you will never be able to undo it (at least, it's very hard to undo and involves Partner Support).
You may want to put all your Person Account dependencies in to an Extension Package to avoid accidentally creating dependencies, but then you'd have to have customers install two separate packages.
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
add a comment |
Is it possible?
Yes.
How would I achieve this?
You need to avoid using any "hard" references to any Person Account features. For example, you'll need to check if IsPersonType is a valid field:
Boolean isPersonAccountsEnabled = sObjectType.RecordType.fields.getMap().containsKey('IsPersonType');
Since this field is only present when you have Person Accounts enabled, you have to do dynamic queries to avoid making a hard link:
RecordType[] personTypes = Database.query('SELECT Id FROM RecordType WHERE IsPersonType = true');
And so on. You can read more about Dynamic Apex in the documentation.
Finally, and I cannot stress this enough, always check the package dependencies before uploading. If you upload a version that includes dependencies to Person Accounts, you will never be able to undo it (at least, it's very hard to undo and involves Partner Support).
You may want to put all your Person Account dependencies in to an Extension Package to avoid accidentally creating dependencies, but then you'd have to have customers install two separate packages.
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
add a comment |
Is it possible?
Yes.
How would I achieve this?
You need to avoid using any "hard" references to any Person Account features. For example, you'll need to check if IsPersonType is a valid field:
Boolean isPersonAccountsEnabled = sObjectType.RecordType.fields.getMap().containsKey('IsPersonType');
Since this field is only present when you have Person Accounts enabled, you have to do dynamic queries to avoid making a hard link:
RecordType[] personTypes = Database.query('SELECT Id FROM RecordType WHERE IsPersonType = true');
And so on. You can read more about Dynamic Apex in the documentation.
Finally, and I cannot stress this enough, always check the package dependencies before uploading. If you upload a version that includes dependencies to Person Accounts, you will never be able to undo it (at least, it's very hard to undo and involves Partner Support).
You may want to put all your Person Account dependencies in to an Extension Package to avoid accidentally creating dependencies, but then you'd have to have customers install two separate packages.
Is it possible?
Yes.
How would I achieve this?
You need to avoid using any "hard" references to any Person Account features. For example, you'll need to check if IsPersonType is a valid field:
Boolean isPersonAccountsEnabled = sObjectType.RecordType.fields.getMap().containsKey('IsPersonType');
Since this field is only present when you have Person Accounts enabled, you have to do dynamic queries to avoid making a hard link:
RecordType[] personTypes = Database.query('SELECT Id FROM RecordType WHERE IsPersonType = true');
And so on. You can read more about Dynamic Apex in the documentation.
Finally, and I cannot stress this enough, always check the package dependencies before uploading. If you upload a version that includes dependencies to Person Accounts, you will never be able to undo it (at least, it's very hard to undo and involves Partner Support).
You may want to put all your Person Account dependencies in to an Extension Package to avoid accidentally creating dependencies, but then you'd have to have customers install two separate packages.
answered Mar 19 at 7:41
sfdcfoxsfdcfox
262k12209454
262k12209454
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
add a comment |
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
You sir are a scholar and a gentleman
– Robs
Mar 19 at 7:45
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f254386%2fis-it-possible-to-deploy-apex-code-which-uses-person-accounts-to-an-org-which-do%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
