I have a test method which I am trying to run from a particular profile. I am trying to access an object called Interaction and that profile has real all record permission.

When I am running the first query it is working fine and returning results.

system.debug([SELECT Id FROM Interaction]);

This one fails with an error message secure query included inaccessible field.

system.debug([SELECT Id FROM Interaction WITH SECURITY_ENFORCED]);
  • Your user doesn't have access to the object being queried. Make sure the user's license type allows access, and that the user has the appropriate permissions.
    – sfdcfox
    Apr 24, 2022 at 17:50
  • I checked that profile and it has Read all permission checked for the Interaction object.
    – Ishan
    Apr 24, 2022 at 18:28
  • Did the user have permission to use the Financial Service Cloud? Again, this error is telling you that the user doesn't have access.
    – sfdcfox
    Apr 24, 2022 at 19:05
  • No. How can I give this permission to the user in the test context?
    – Ishan
    Apr 24, 2022 at 19:16


You must log in to answer this question.