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
Rahul AlladaRahul Allada 

forceChatter:feed is not working as expected

I am trying to use forceChatter:feed from (https://developer.salesforce.com/docs/component-library/bundle/forceChatter:feed/documentation).

The below code is working fine and the result is as expected.
<aura:component controller="chatterController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" access="global" />
      <aura:attribute name="contactList" type="id" />
    <forceChatter:feed type="Record" subjectId="a091y000000fXREAA2" /> //Passing Record Id directly
</aura:component>
Whereas if I pass the SubjectId with some attribute value, results are not getting displayed as expected.
<aura:component controller="chatterController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" access="global" />
      <aura:attribute name="contactList" type="id" />
    <forceChatter:feed type="Record" subjectId="{!v.contactList}" /> //Passing Variable which has record-id(a091y000000fXREAA2) directly
</aura:component>
Not able to find what's the exact reason why the results are not displayed properly when I pass subjected with a variable which has the record Id.
SwethaSwetha (Salesforce Developers) 
HI Rahul,
As mentioned in the post(https://salesforce.stackexchange.com/questions/167640/forcechatterpublisher-not-loading) , Unlike force:recordEdit/reviewView the forceChatter:feed component does not support dynamically changing v.subjectId 

To fix this,you need to use $A.createComponent() inside of your doInit() to construct the feed dynamically.

Sample code:
$A.createComponent(
"forceChatter:publisher", {
    "context": "RECORD",
    "recordId": ideaselected
},
function(recordFeed) {
    //Add the new button to the body array
    if (component.isValid()) {
        var body = component.get("v.body");
        body.push(recordFeed);
        component.set("v.body", body);
    }
}); 

$A.createComponent(
"forceChatter:feed", {
    "type": "Record",
    "subjectId": ideaselected
},
function(recordFeed) {
    //Add the new button to the body array
    if (component.isValid()) {
        var body = component.get("v.body");
        body.push(recordFeed);
        component.set("v.body", body);
    }
});
Salesforce documentation related to same: https://developer.salesforce.com/docs/component-library/bundle/forceChatter:feed/documentation

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you​​​​​​​
SwethaSwetha (Salesforce Developers) 
HI Rahul,
I see you also posted this ask on https://salesforce.stackexchange.com/questions/334647/forcechatterfeed-is-not-working-as-expected and the solution is

" let me explain why the above thing is not working. As I am getting Id from the controller and in return, the Id is getting returned from the Apex controller and it's taking time as it is an asynchronous process and hence when the tag is getting rendered it is getting rendered as undefined.
Hence, to solve this issue, add this component in the controller and dynamically create it as follows:"

I see the code snippet you used is similar to above comment
$A.createComponent(
                    "forceChatter:feed", {
                        "context": "RECORD",
                        "subjectId": response.getReturnValue()
                    },
                    function(recordFeed) {
                        if (component.isValid()) {
                            var body = component.get("v.body");
                            body.push(recordFeed);
                            publisher.set("v.body", body);
                        }
                    });

Please consider marking this answer as best to close the thread and to help others facing the same issue.