Quantcast
Channel: Active questions tagged feeditem - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 160

Unable to write BestCommentId on FeedItem in test class

$
0
0

I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data that I am creating is as follows -

FeedItem fi = new FeedItem(Title = 'Feed Title',ParentId = parentId,Type = 'QuestionPost');
insert fi;
FeedComment fc = new FeedComment(CommentBody = 'Comment Body',FeedItemId = fi.Id);
insert fc;
fi.BestCommentId = fc.Id;
update fi;

I get an exception on fi.BestCommentId = fc.Id line that says Field is not writeable: FeedItem.BestCommentId. Is there a way to do this? Especially without using seeAllData=true.


Viewing all articles
Browse latest Browse all 160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>