Is there a way to retrieve Community user's contact fields in force:recordData? This is my first lightning coming, and I'm not finding proper information on this.

I'm trying to display the logged in user's contact information in the community.

1 Answer 1


force:recordData needs an id of a record to render the details of that record. So as long as you have the logged in User's details, you can retrieve the associated Contact Id from that using the ContactId field and pass it on to your lightning component.

To be able to fetch the Contact Id from the logged in User, you can use a query as below.

SELECT ContactId FROM User where Id = 'logged in user's id'

And then you you can utilize the Contact Id as retrieved above on your lightning component as:

<force:recordData aura:id="forceRecordCmp" recordId="{!v.contactId}" .... />
  • I'm starting down this path now and curious about the timing of the loading of this. can one component fetch the contact id from a controller and then update the force:recorddata recordid field? or would i need to have a parent component to get it first and pass it into a component once loaded? I also want to edit the record from the ui fields without binding, custom validation then say forcerecord.fields.set.field:value
    – textual
    Aug 9, 2018 at 20:49
  • The short answer to your queries is Yes. You can fetch the id in a component’s say init method and then have the id passed on to another component which has the force:recordData implementation.
    – Jayant Das
    Aug 9, 2018 at 21:01

You must log in to answer this question.

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