0

The Apex code is creating some custom object (NOT records, creating the custom object itself), but is only working when executed by admins. Otherwise, users get INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY - even when they have "API Enabled", "View All Data" and "Modify All Data" permissions.

Am I missing another permission to give? I went through the questions with the same error but none seem to match my scenario.

9
  • Can you check, Respective user have CRUD permissions on custom object related object Jun 1, 2022 at 14:05
  • The custom object has no related object (except User for the default fields such as ownerId)
    – user7094
    Jun 1, 2022 at 14:11
  • Have you verified the below troubleshooting steps? 1. Make sure whether the user have access to record ids of the lookup fields and/or master-detail fields in the record. 2. Check the user Profile(CRUD Permissions). 3. Profile need to have access for the record types. 4. Record's OwnerId automatically gets share record when the record is inserted. If the apex code try to create the same(Share record for the owner) explicitly. This error occurs. Jun 1, 2022 at 14:11
  • 2
    @user7094 most probably users dont have Customize application permission which is required to create custom object. help.salesforce.com/s/…
    – Shamina
    Jun 1, 2022 at 19:14
  • 1
    @Shamina that was indeed what I was missing. Thanks!
    – user7094
    Jun 2, 2022 at 20:05

1 Answer 1

1

As mentioned in comments, Customize application is required to create custom object from the apex code.

Note: adding this permission to non-admin users, means that users will also be able to create custom object from UI setup menu in salesforce.

Reference from documentation :

USER PERMISSIONS NEEDED To create and edit custom objects: Customize Application

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.