I know the field is not editable but I mean by associating a User record with a Contact/Person Account record in your test data, somehow it gets enabled? Do you know?

The reason I need this ability is to be able to test some custom merge functionality where one of the two person accounts being merged have a Community user associated with it and depending on which one has the user to it, determines how the merge occurs. I would hate having to have to use Test.isRunningTest() to bypass this.

EDIT: I guess, another way of asking this question is, is there a programmatic way of "Enable Community User" button on Person Accounts / Contacts

  • Given that User records are visible in a test context, have you tried simply querying for the records? – Adrian Larson Apr 12 '19 at 1:39
  • @AdrianLarson Unless I'm querying for Community users already in the system, the query returns nothing. I need to create test users from my test class and execute this because not all environments will have the right set of users to query – Vid L Apr 18 '19 at 20:18
  • You just need those records to exist in production, as well as at least one source environment (hopefully you have a full sandbox), – Adrian Larson Apr 18 '19 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.