1

On Community we have standard component Feed Publisher, which has parameter Record ID. Standard value is {!recordId}. On the same page we have a custom Lightning component. Is it possible to pass record ID from the custom component to the Feed Publisher or other standard component on page load?

2
  • You wanna set recordId for feedPublisher from your custom component and not accept the recordId from the current page? Jul 8, 2019 at 12:10
  • @PranayJaiswal yes. I want to query different ID and pass it to the Feed Publisher
    – mascot
    Jul 8, 2019 at 12:24

1 Answer 1

0

You'll have to create a custom "wrapper" component for the feed component that can communicate with your other custom component. In the example below we're using the ltng:selectSObject event over creating our own custom event, since all we need to communicate is a record ID, which is what this standard event type provides.

<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
    <aura:attribute name="overriddenRecordId" type="string" access="global" />
    <aura:handler event="ltng:selectSObject" action="{!c.handleRecordSelection}"/>
    <forceChatter:feed type="record" subjectId="{!v.overriddenRecordId}"/>
</aura:component>

Your js controller would have a handleRecordSelection that would retrieve the record ID from the event and set the overriddenRecordId attribute with that value.

You could add an init handler that initializes the overriddenRecordId value to the page's record ID if it has one via the force:hasRecordId interface.

Your other component would fire the ltng:selectSObject event with the appropriate record ID when it wants the feed's record ID to change.

IMPORTANT CAVEAT: There's nothing in the documentation that says the forceCommunity:feed component can't be used in a Lightning Community, but I haven't tested it myself, so you'll want to do a smoke test first to make sure it gives you the kind of Feed that you're looking for.

You must log in to answer this question.

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