0

On a custom Aura component, I have defined an sobject attribute as

<aura:attribute name="localVatInst" type="CustomObject__c" default="{'sobjectType':'CustomObject__c'}" /> 

If user does not have access to it, they see an error like

Invalid definition for CustomObject__c: Access to entity 'CustomObject__c' denied

How do I check the user has access to this object? I see that even the init is not called yet.

EDIT: I KNOW the user does not have access to the object. As multiple users will be using this component, I wanted to put a check.

2
  • check their profile and permission sets assigned to see If they have access? Also, can you add some more context to your question? Like is it a custom component or you have any base components and so on May 2, 2020 at 22:47
  • I know they don't have access to the object. My query is, how do I check whether the user who is viewing the component has access to any object that is referred in custom aura component?
    – pmehta28
    May 3, 2020 at 8:02

1 Answer 1

2

The error is coming because the user does not have access to the object.

A user must have at least Read access to the object specified in the attribute type. Otherwise, the component doesn't load.

Incase this component is being used by multiple users some of which have access and some don't, then the access check should happen before this component is loaded.

You can wrap this component in another component which does the access check and renders the component

OR

you will need to change the aura attribute definition and apex implementation from CUSTOMOBJECT__C to OBJECT which has same properties as your custom object, send the map to the apex on clicking an action button and construct the SObject in the controller if a DML is involved.

Aura:

<aura:attribute name="localVatInst" type="Object" default="{'Field1__c':'','Field2__c:''}"/> 

Controller:

public static void doSomeAction(String jsonStringifiedObjectBodyHere){
    //Deserialize here
}
0

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.