2

My lightning component -

<aura:component access="GLOBAL" implements="forceCommunity:availableForAllPageTypes,force:appHostable">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <!-- <ltng:require scripts="/resource/jqueryminjs" afterScriptsLoaded="{!c.doInit}"/> -->
    <aura:attribute name="articleId" type="String" access="global" />
    <forceChatter:feed type="Record" subjectId="{!v.articleId}" />
    <p><b>{!v.articleId}</b></p>
</aura:component>

and client controller -

({
    doInit : function(component, event, helper) {
        var currentArticleUrl = window.location.href;
        var articleId = helper.getURLParameter('id');

        if (articleId != null) {
            console.log('article Id -->', articleId );
            component.set("v.articleId", articleId);
        }
    }
})

Helper code -

({
    getURLParameter : function(name) {
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
    }
})

Article Id is coming from url parameter. So url can be something like-

https://domain.lightning.force.com/c/TestKnowledgeArticleApplication.app?id=ka07E0000004IVGQA2

I checked that article Id is coming properly on component

tag and client side controller, but the tag even though using the same attribute does not get the value. I am using this in Napili template component.

8
  • So you mean forceChatter:feed is not working ? May 25, 2016 at 15:48
  • Yes, for dynamic value. But if I test it with hardcoded values the forceChatter:feed works properly May 25, 2016 at 15:49
  • Is there a difference in no of digits in Id ? May 25, 2016 at 15:59
  • Also if you could provide the controller code ,so i can dig into this May 25, 2016 at 16:01
  • 1
    Behaving same way for account id as well. So most probably something with lightning component and controller communication which is missing May 25, 2016 at 16:54

2 Answers 2

4

Unlike force:recordEdit/reviewView the forceChatter:feed component does not support dynamically changing v.subjectId - I just went and looked and there is no logic in the component to trigger reloading the feed when subjectId changes. The component does have a refreshFeed() method but its not marked access="GLOBAL" so no joy there either. Same for the refresh event handler.

All is not lost though - I would switch to using $A.createComponent() inside of your doInit() to construct the feed dynamically - not hard to do - and then your existing container component will work just fine.

2
  • 1
    The forceChatter:feed has numerous bug .It would be helpful if we get some road maps around the fix or alternative so we update our clients making decision .Thanks May 25, 2016 at 23:31
  • I will give it a try but looks like there is a workaround May 26, 2016 at 8:57
2

Below is the sample code that I got this working

<!--c:createComponent-->
<aura:component>
  <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  <aura:attribute name="articleId" type="String" access="global" />
   <p>Dynamically created Feed</p>
{!v.body}
</aura:component>

The component JS controller code

/*RecordFeedController.js*/
({
doInit : function(cmp,helper) {
    var currentArticleUrl = window.location.href;
    var articleId = helper.getURLParameter('id');
    $A.createComponent(
        "forceChatter:feed",
        {
            "type": "Record",
            "subjectId": articleId
        },
        function(recordFeed){
            //Add the new button to the body array
            if (cmp.isValid()) {
                var body = cmp.get("v.body");
                body.push(recordFeed);
                cmp.set("v.body", body);
            }
        }
    );
   },
 })

enter image description here

Irrespective of the answer ,this looks not PRODUCTION ready outside lightning experience especially lightning out.There seems to be numerous bug with styling and actions that's noticeable on console outside builders and lightning experience so avoid using this component in PROD and raise a bug with support so they fix it

1
  • Thanks for the code. UI works perfect with templates inside community but if we try to use it in a normal lightning app then it breaks. so for me using the UI in Napili template works like a charm May 26, 2016 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.