[SalesForce] How to check edit access for LWC

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.

Best Answer

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.

Related Topic