You need to sign in to do that
Don't have an account?
_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!
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!
I’m guessing stuff initialized in the wrong order…
Following MIGHT work
(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
I’m guessing stuff initialized in the wrong order…
Following MIGHT work
(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?)
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?
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