8 thoughts on “How to Display Current User Information In Lightning Component – Sample”

  1. thanks good post piyush soni,
    How to get all list of logged users in Salesforceforce org and Display in Lightning component

    Reply
  2. If email address is ‘[email protected] on user profile, we can fetch the User name from email on user profile without server call.

    Lightning Component :

    <aura:component implements=”flexipage:availableForRecordHome>
    <aura:attribute name=”UserName” type=”String” default=””/>
    </aura:component>

    javaScript controller :

    ({ doInit : function(component, event, helper) {
    var UserName =  $A.get(“$SObjectType.CurrentUser.Email”);
    cmp.set(“v.UserName”,(UserName.substring(0, UserName.lastIndexOf(“@”))));
    alert(cmp.set(“v.UserName”));
    }
    })
     

    Reply
  3. Hi Piyush,

    var userId = $A.get(“$SObjectType.CurrentUser.Id”);
    alert(userId);

    similar way can we get profile Name?
    Please advice.

    Thanks & Regards,
    Chethan

    Reply

Leave a Comment