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










5















I want to create a managed package which supports orgs both with and without PersonAccounts enabled.



  1. Is it possible?

  2. How would I achieve this?









share|improve this question


























    5















    I want to create a managed package which supports orgs both with and without PersonAccounts enabled.



    1. Is it possible?

    2. How would I achieve this?









    share|improve this question
























      5












      5








      5








      I want to create a managed package which supports orgs both with and without PersonAccounts enabled.



      1. Is it possible?

      2. How would I achieve this?









      share|improve this question














      I want to create a managed package which supports orgs both with and without PersonAccounts enabled.



      1. Is it possible?

      2. How would I achieve this?






      apex managed-package person-accounts






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 19 at 7:25









      RobsRobs

      2,295537




      2,295537




















          1 Answer
          1






          active

          oldest

          votes


















          8















          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.






          share|improve this answer























          • You sir are a scholar and a gentleman

            – Robs
            Mar 19 at 7:45










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



          );













          draft saved

          draft discarded


















          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









          8















          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.






          share|improve this answer























          • You sir are a scholar and a gentleman

            – Robs
            Mar 19 at 7:45















          8















          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.






          share|improve this answer























          • You sir are a scholar and a gentleman

            – Robs
            Mar 19 at 7:45













          8












          8








          8








          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.






          share|improve this answer














          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 19 at 7:41









          sfdcfoxsfdcfox

          260k12207452




          260k12207452












          • 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





          You sir are a scholar and a gentleman

          – Robs
          Mar 19 at 7:45

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Rank groups within a grouped sequence of TRUE/FALSE and NAGrouping functions (tapply, by, aggregate) and the *apply familyCharacters counting and subletting specific patternsWhat is the purpose of setting a key in data.table?data.table vs dplyr: can one do something well the other can't or does poorly?how to make a bar plot for a list of dataframes?How to group by unique values in a list in RPandas - Alternative to rank() function that gives unique ordinal ranks for a columnRank within group in for loop in RData transformation: from dyadic to observational data in RGetting map from purrr to work with paste0

          Are all passive ability checks floors for active ability checks?Does passive perception supersede active perception?Which skills can be used passively?Active Opposition with Free-Form Professions in Fate5E Trap/Ambush/Stealth Mechanics VS Passive Perception ConfusionInteraction between perception and stealth in obscured conditionsHow does Keen Sight affect Passive Perception?Are all d20 rolls either attacks, saves or ability checks?Can players declare that they are making a specific ability check?Can I see a Hidden creature that is not obscured at all?Can a Stealth check ever be made passively?Is this alternate version of the Observant feat balanced?What is the minimum amount of skill points per HD?

          Quoting Keynes in a lectureIs differentiated instruction permitted by universities?How to make students learn prerequisitesUnsatisfactory Instructor Evaluations: balancing of expectations of engineering studentsWhat is the difference between a “statistician”, “applied statistician”, and an academic applying advanced stats within their field?Listing in reference section, but not quotingHow to efficiently use time while preparing for a class?Graduate Admissions: Teaching Emphasisstrategies for sharing teaching information with universities I don't personally have contacts withIs there an efficient way to give a large class of students feedback about their assignments?Is it unreasonable to expect students to read the lecture notes before attending the first class?