get User-Id In Lightning Web Component Salesforce

by Rijwan Mohmmed
How-to-get-User-Id-In-Lightning-Web-Component(LWC)-Salesforce

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
0
+1
0
+1
0
+1
0
+1
0
+1
0

You may also like

Leave a Comment