3

I am just going through the Summer 20 Release Notes and found an article - Check User Permissions for Lightning Web Components

Here is the link

Here I found, to check View Setup permission you just have to import ->

import hasViewSetup from '@salesforce/userPermission/ViewSetup';

I just want to know is there any User permission to check Edit Access so that I can import directly and use in My LWC.

1 Answer 1

4

No, as there's already a solution available: getObjectInfo.

Here's the example from the documentation:

import { LightningElement, wire } from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';

export default class Example extends LightningElement {
    @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
    propertyOrFunction;
}

Since it's a wire method, this is actually reactive, in case the permissions change for some reason, your component will be notified of the change in permissions without having to reload the component.

4
  • I have to restrict user to enter in input field if the user does not have access to that field and without using apex, is this possible only in LWC? Commented Jun 26, 2020 at 12:39
  • @SahilMalhotra Yes, the ObjectInfo response includes the fields and their editability.
    – sfdcfox
    Commented Jun 26, 2020 at 13:01
  • Also, check this out, I have tried exploring getObjectInfo deep : - OBJECT INFORMATION IN LIGHTNING WEB COMPONENT Commented Jun 26, 2020 at 14:47
  • Hi all, I checked with getObjectInfo but did not get the name that checks the Editability of fields. I have checked with admin profile and other profile who do not have access to that field, but nothing change in wired result. So please tell me from which I can check the editability of field so I can restrict the user to access the field in LWC Commented Jun 29, 2020 at 5:10

You must log in to answer this question.

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