We can get the current user-Id in Lightning Web Component in Salesforce, for this we need to import the
import UserId from '@salesforce/user/Id';
Lets learn with a simple example :
mycomp.html :
<template>
<div>
<h2> User Id : {currentUserId} </h2>
</div>
</template>
mycomp.Js :
import { LightningElement } from 'lwc';
import UserId from '@salesforce/user/Id';
export default class MyComp extends LightningElement {
currentUserId = UserId;
}
What’s your Reaction?
+1
+1
+1
+1
+1
+1