2

To simplify tests with community users, I am trying to configure the default community for a specific profile.

Running this in Anonymous Apex, or trying to save my class containing the code:

insert new NetworkAffinity(NetworkId = '0DBJ00000008OXFOA2', ProfileId ='00eJ0000000QeWS');

results in:

DML operation Insert not allowed on NetworkAffinity

But the Documentation says:

Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

Special Access Rules

To work with the NetworkAffinity object, you must have View Setup or Customize Application permission.

I am a System Admin that has View Setup and Customize Application permissions. Updating an existing record didn't work either.

I never payed attention to these sections cause in general they were accurate. Am I missing something or are they just wrong in this case?

5

The list of functions refer to API calls, not Apex objects. There are plenty of objects that show as CRUD or so in the documentation, but will not work in Apex. Instead, you would need to query an existing record and use that in your test. Objects that are not writable in Apex are typically queryable without the use of @isTest(SeeAllData=true).

  • Thanks for your fast response, and the additional information, that makes it clear. – Basti Dec 18 '18 at 18:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.