Reference Link :
https://rajvakati.com/2019/02/11/get-current-user-details-in-lightning-web-components/
JS File
import strUserId from '@salesforce/user/Id';
import PROFILE_NAME_FIELD from '@salesforce/schema/User.Profile.Name';
import {getRecord} from 'lightning/uiRecordApi';
export default class RoleManager extends LightningElement {
@track prfName;
userId = strUserId;
@wire(getRecord, { recordId: '$recordId', fields: ['account.OwnerId'] })
mom;
@wire(getRecord, {
recordId: strUserId,
fields: [PROFILE_NAME_FIELD]
}) wireuser({
error,
data
}) {
if (error) {
this.error = error ;
} else if (data) {
this.prfName =data.fields.Profile.value.fields.Name.value;
}
}
get showToOwner() {
if(this.mom.data.fields.OwnerId.value === strUserId || this.prfName ===
'System Administrator' )
return true;
}
No comments:
Post a Comment