Component:
Controller:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" > <aura:attribute name="currentUser" type="User" /> <force:recordData fields="Username,Name, Email" recordId="{!$SObjectType.CurrentUser.Id}" targetFields="{!v.currentUser}" mode="VIEW" /> <lightning:button variant="brand" label="Load Report" onclick="{! c.handleClick }" /> </aura:component>
({ handleClick : function(component, event, helper) { var UserName = $A.get("$SObjectType.CurrentUser"); alert(' User Name--- '+component.get("v.currentUser.Username"));
alert(' Name --- '+component.get("v.currentUser.Name")); } })
Thanks Manju, this helps
ReplyDelete