1

I am trying to create a custom chatter feed in my Visual Force page. I am using the Apex repeat tag to try to create a list of posts from the chatter feed. I have this working perfectly for a feed that is using the "me" SubjectID.

However I want to be able to set it up for a specific Record and thus pass it the Record ID.

When my Visual Force page loads I get the recordID and I have an extension that I use to get the feed.

The code I use in the APEX Class that is my extension is as follows:

public with sharing class recordFeedController {

public ConnectApi.FeedItemPage feedItemPage{get;set;}

public String RecordId { get; set; } //I want to be able to set this from my Visual Force page

public recordFeedController(ApexPages.StandardController stdController) { //<-- Could I pass the record ID in here somehow?
    // Get the chatter record feed.
    feedItemPage = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null,ConnectApi.FeedType.Record, RecordId);
}

The outline of my Visual Force page is as follows:

<apex:page standardcontroller="Record_c" extensions="recordFeedController" cache="false"
       docType="html-5.0" sidebar="false" showheader="false" standardStylesheets="false">

....

<apex:param name="RecordId " value="{!recordId}" assignTo="{!RecordId }"/> 
//I get recordId from my standard controller Record_c and try the above to send it to the RecordID variable in recordFeedController extension

....

<apex:repeat value="{!feedItemPage.items}" var="feedItem">
....
</apex:repeat>
//I use the feeditemPage in an Apex repeat to display the chatter feed on the creation of the page but I need to send it the RecordID before it gets created, help!

</apex>

If I hard code a valid record ID here everywork works fine:

ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null,ConnectApi.FeedType.Record, "123456789");

So I really need to know how I pass the Record ID I have in my Visual Force page to my recordFeedController class as soon as my Visual Force page is created and before the Apex repeat structure is built. Can anyone help point me in the right direction for that?

I am only 1 week into learning SalesForce so any guidance would be greatly appreciated.

1 Answer 1

1

In your constructor you can get the id by stdController.getId();

e.g.

public recordFeedController(ApexPages.StandardController stdController) { //<-- Could I pass the record ID in here somehow?
    // Get the chatter record feed.
RecordId = strController.getId();
    feedItemPage = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null,ConnectApi.FeedType.Record, RecordId);
}
0

You must log in to answer this question.

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