[SalesForce] LWC -ightning/uiObjectInfoAPI – getting INSUFFICIENT_ACCESS error for custom object

I am trying to get metadata info for a custom object using lightning/uiObjectInfoAPI’

here is what I am doing:

wire(getObjectInfo, { objectApiName: BATCH_OBJECT })
    getBatchObjectInfo({data,error})
    {
        console.log('getbatchobjectinfo');
        if(data){
            console.log('the data :'+JSON.stringify(data.fields));
            this.name = data.fields[BATCH_OBJECT_NAME.fieldApiName].label;
        }
        else if(error){
            console.log('the error :'+JSON.stringify(error));
            console.error(error);
        }
    }

I am getting the following error:

{"ok":false,"status":403,"statusText":"INSUFFICIENT_ACCESS","body":[{"errorCode":"INSUFFICIENT_ACCESS","message":"You
don't have access to this record. Ask your administrator for help or
to request access."}]}

I checked the system admistrator profile in my scratch org:
there is access to "Modify Metadata Through Metadata API Functions"

Any reason why is happenning?

I am able to get back all the information related to the object in case of standard object like Account.

Best Answer

Can you create the new VSCode project again or delete org folder in .sfdx folder under the project and again authorize dev hub and create scratch org

Related Topic