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? Commented 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
    Commented 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 Commented 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
    Commented Jan 9, 2020 at 17:42
  • Is it failing for any custom object as well ? Commented Jan 9, 2020 at 17:44

3 Answers 3

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.

0

I don't have as answer, but am experiencing a similar problem. The issue I'm having is with the bulkified version, getObjectInfos, which takes an array of sObject names as the parameter. Those sObjects will be dynamic, passed down as @api parameters.

If I hardcode the parameters into the @wire method, it works.

@wire(getObjectInfos, { objectApiNames: ['Account', 'Contact']})
objectInfos({error, data})

Any ideas?

However, I always get that FORBIDDEN status=403 error if I assign the params dynamically. It appears that the @wire method is firing before the params have values, resulting in that error. Here's what I've tried:

@api linkOne;
@api linkTwo;

@wire(getObjectInfos, { objectApiNames: [this.linkOne, this.linkTwo] }

also tried

@api linkOne;
@api linkTwo;

@wire(getObjectInfos, { objectApiNames: [`$linkOne`, `$linkTwo`] }

also tried passing the array in directly

@api linksList;

@wire(getObjectInfos, { objectApiNames: `$linksList` }

when I console.log that last one, I get Opportunity, Account, so I tried passing the list in as an object value where linksContainer.links = ["Opportunity", "Account"]. When I console.log(linksContainer.links), I get ["Opportunity", "Account"]. But I still get the error when I run:

@api linksContainer;

@wire(getObjectInfos, {objectApiNames : `$linksContainer.links`}

or

@wire (getObjectInfos, {objectApiNames : this.linksContainer.links}
-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
    Commented Jan 10, 2020 at 16:21
  • @Padma: I am facing the same issue. Were you able to resolve it? Commented 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 .