EP-23 | User Permission Based UI in Lightning Web Components | LWC Stack ☁️⚡️

  LWC Stack is Lightning Web Component tutorial series by Salesforce MVP Kapil Batra. In this series you will find LWC tutorials from beginner to intermediate level.

So if you are working on it or planning to learn LWC then this video series is for you. Let's learn and grow together !

Please check complete code below from LWC Stack EP-23

HTML

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<template>
    <lightning-card title="Permission Set UI " icon-name="utility:user">
        <div class="slds-var-m-around_medium">
            <div style="padding:10px">
                <template if:true={isUIAccessible}>
                    <h1>I am available.</h1>
                </template>
                <template if:false={isUIAccessible}>
                    <h1>I am not available.</h1>
                </template>
            </div>
        </div>
    </lightning-card>
</template>
JS
1
2
3
4
5
6
7
8
import { LightningElement } from 'lwc';
import hasAccessUI from '@salesforce/customPermission/myFirstCustomPermission';

export default class PermissionSetUI extends LightningElement {
    get isUIAccessible(){
        return hasAccessUI;
    }
}

Output


Checkout complete video tutorial below

 If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks

Happy Coding :)

Post a Comment

0 Comments