Is it possible to deploy Apex code which uses Person Accounts to an org which doesn't have Person Accounts enabled?2019 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
How can "mimic phobia" be cured or prevented?
Does IPv6 have similar concept of network mask?
Yosemite Fire Rings - What to Expect?
Why "had" in "[something] we would have made had we used [something]"?
Can I say "fingers" when referring to toes?
Why is this estimator biased?
Limits and Infinite Integration by Parts
15% tax on $7.5k earnings. Is that right?
Why did the EU agree to delay the Brexit deadline?
Quoting Keynes in a lecture
Are Captain Marvel's powers affected by Thanos' actions in Infinity War
What should you do if you miss a job interview (deliberately)?
I'm the sea and the sun
Why can Carol Danvers change her suit colours in the first place?
It grows, but water kills it
What are the advantages of simplicial model categories over non-simplicial ones?
Has any country ever had 2 former presidents in jail simultaneously?
Keeping a ball lost forever
Terse Method to Swap Lowest for Highest?
Why is the "ls" command showing permissions of files in a FAT32 partition?
Calculating total slots
Why does a simple loop result in ASYNC_NETWORK_IO waits?
How to explain what's wrong with this application of the chain rule?
Why should universal income be universal?
Is it possible to deploy Apex code which uses Person Accounts to an org which doesn't have Person Accounts enabled?
2019 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,295537
2,295537
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 |
Your Answer
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
260k12207452
260k12207452
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