function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
_ax21_ax21 

Custom Lightning chatter component not working when using custom record ID

I'm creating a custom chatter component for the Event report page.
But i don't want the chatter component to track/display feed for the Event object,
i want the custome chatter component to track/display feed for a different custom object and i'm having some trouble doing this.  

Component code: 

<aura:component controller="EventLightningController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="EventDetail" type="EventDetail__c" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 
    <aura:attribute name="eventDetailID" type="Id" default="{!v.EventDetail.Id}"/>   
    <!-- prints a100k0000008hnaAAA -->
    <p><ui:outputRichText value="{!v.eventDetailID}" /> </p>    
    <!-- using Event obj ID works -->
    <forceChatter:publisher context="RECORD" recordId="{!v.recordId}" />
    <forceChatter:feed type="Record" subjectId="{!v.recordId}"/> 
    <!-- hard coding works -->
    <forceChatter:publisher context="RECORD" recordId="a100k0000008hnaAAA" />
    <forceChatter:feed type="Record" subjectId="a100k0000008hnaAAA"/> 
    <!-- Custom object id not working?? -->                                            
    <forceChatter:publisher context="RECORD" recordId="{!v.eventDetailID}" />
    <forceChatter:feed type="Record" subjectId="{!v.eventDetailID}"/> 
</aura:component>

Thank in advance!
Best Answer chosen by _ax21
ChristinaRallChristinaRall

I’m guessing stuff initialized in the wrong order…
Following MIGHT work

<aura:if isTrue="{!v.eventDetailID}">
 <forceChatter:publisher context="RECORD" recordId="{!v.eventDetailID}" />
    <forceChatter:feed type="Record" subjectId="{!v.eventDetailID}"/> 
</aura:if>

(PS. I saw you posted this in the Salesforce Stack Exchange as well. Will you please cross post whatever solution ends up working for you so that if someone has a similar problem, the solution will be easy to find?)

All Answers

ChristinaRallChristinaRall

I’m guessing stuff initialized in the wrong order…
Following MIGHT work

<aura:if isTrue="{!v.eventDetailID}">
 <forceChatter:publisher context="RECORD" recordId="{!v.eventDetailID}" />
    <forceChatter:feed type="Record" subjectId="{!v.eventDetailID}"/> 
</aura:if>

(PS. I saw you posted this in the Salesforce Stack Exchange as well. Will you please cross post whatever solution ends up working for you so that if someone has a similar problem, the solution will be easy to find?)
This was selected as the best answer
_ax21_ax21
Hi Christina, 
You helped me to get on the right track. I think there's some rendering sequence. the component was trying to display chatter with eventDetailID attribute, and the attribute was empty if "init" takes too long. The <if> tag helps it and it would load correctly. Howeve, would this be a permanent solution? 
_ax21_ax21
nvm, after looking at the documentation for aura:if, it looks like it helps to render the body. Thank Christina

aura:if Conditionally instantiates and renders either the body or the components in the else attribute. aura:if evaluates the isTrue expression on the server and instantiates components in either its body or else attribute. Only one branch is created and rendered. Switching condition unrenders and destroys the current branch and generates the other
ChristinaRallChristinaRall
Glad I could help