4

I am just trying to get the user details on the page using LDS.

<force:recordData aura:id="userRecord"
                      recordId="{!v.userrecordId}"
                      targetRecord="{!v.record}"
                      targetFields="{!v.simpleRecord}"
                      fields="Id,
                              Name"
                      />
    <ui:outputText class="slds-output" aura:id="recordName"
                   value="{!v.simpleRecord.Name}" />

JS:

var userId = $A.get("$SObjectType.CurrentUser.Id");

In JS, I can get the current user ID, Since I get the Current User ID, is that possible to set the force:recordData recordId and print the field values?

I am trying to see if we can userinfo without apex.

1 Answer 1

7

Yes, you can:

<aura:application >
    <aura:attribute name="record" type="Object" />
    <force:recordData recordId="{!$SObjectType.CurrentUser.Id}"
                      layoutType="FULL"
                      targetFields="{!v.record}" />
    {!$SObjectType.CurrentUser.Id}: {!v.record.Name}
</aura:application>
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .