3

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.

11
  • what is the object with variable named BATCH_OBJECT? Jan 9, 2020 at 16:33
  • it is a custom object : Batch_Log__c, I had to remove the name space in js file as it was complaining about it. I have this is js file : import BATCH_OBJECT from '@salesforce/schema/Batch_Log__c';
    – Padma
    Jan 9, 2020 at 16:48
  • Check your Profile access to the Batch_Log__c object ? Looks like your profile does not have read access to the Batch_Log__c object Jan 9, 2020 at 17:08
  • 1
    sharing acces on Batch_Log__c is : Public Read/Write, i am system administrator for my scratch org, I have read and edit access to all the fields in the object. Also, i have Read Create Edit Delete View All Modify All for this Custom Object Permissions. I feel the error is regarding some permission with metadata access. Also, system admin profile has this access too : Modify Metadata Through Metadata API Functions Checked
    – Padma
    Jan 9, 2020 at 17:42
  • Is it failing for any custom object as well ? Jan 9, 2020 at 17:44

2 Answers 2

0

Can you check if there is a reference field in your call that is locked from access that you cannot see due to permissions/sharing? It would appear that this would also throw out an error as you may not have access to the object on the other end of that relationship field so the error is being thrown as it would attempt to pull the Id and Name from reference fields used in the layout.

-1

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

2
  • 1
    I will try doing this, but my code is already in git etc. this functionality is working with a seperate LWC, but in main LWC works for standard objects not custom objects-thanks!
    – Padma
    Jan 10, 2020 at 16:21
  • @Padma: I am facing the same issue. Were you able to resolve it? Dec 22, 2021 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .