You need to sign in to do that
Don't have an account?
d3developer
Accessing Feedpost.Body with SObject.get('FeedPost.Body')
I'm trying to write a function to merge comments and posts from one feed to another. Sadly I get this error (from the debug log) :
13:28:14.418|SOQL_EXECUTE_BEGIN|[343,39]|Aggregations:0|SELECT id, FeedPost.Body from ChatterTasks__ToDoItem__Feed where id = '0D5A0000000GoXbKAK' limit 1
13:28:14.431|SOQL_EXECUTE_END|[343,39]|Rows:1|Duration:13
13:28:14.431|METHOD_EXIT|[343,39]|query(String)
13:28:14.431|METHOD_ENTRY|[347,47]|SObject.get(String)
13:28:14.431|METHOD_EXIT|[347,47]|get(String)
13:28:14.431|METHOD_ENTRY|[348,52]|SObject.get(String)
13:28:14.431|EXCEPTION_THROWN|[348,52]|System.SObjectException: Invalid field FeedPost.Body for ChatterTasks__ToDoItem__Feed
When I run this code:
for(String id : activeSObjectFeedItems) {
try {
String feedObjectName = feedObjectName(activeSObjectType);
String queryString = 'SELECT id, FeedPost.Body from ' + feedObjectName + ' where id = \'' + id + '\' limit 1';
List<SObject> sos = Database.query(queryString);
FeedComment fcomment = new FeedComment();
fcomment.FeedItemId = (Id) sos[0].get('id');
fcomment.CommentBody = (String) sos[0].get('FeedPost.Body');
insert fcomment;
}
catch(Exception e) {
System.debug('MergeFeed: ' + e);
}
}
But I can't think of a workaround since I can't query the FeedPosts directly.
Ideas?
This worked for me
All Answers
its something like sos[0].get("FeedPost").get("Body")
Doesn't quite work.
Get this when I try to save:
Also tried this:
But gives me this error:
Were you able to resolve this? I'm having the same issue.
Nope. Made my generic Feed merge tool somewhat less than I hoped.
SimonF -- Do you have any new information to add? :smileyhappy: I'm trying to make a generic Visualforce feed component, and this is a major roadblock.
This worked for me
Simon, you're the man :) This worked perfectly. I was missing the ".getSObject"
cool.