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
matt lieber 5matt lieber 5 

Trigger giving compile error on referencing standard field on standard object

hi,
my trigger and the problem is as such:
User-added image
Not understanding the error; 'Body' is a standard field on FeedItem, according to this : 
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm
So what's the problem ? 
thanks!
Matt
Best Answer chosen by matt lieber 5
SandhyaSandhya (Salesforce Developers) 
Hi Matt Lieber,

replace you code 

comment.FeedCommentBody__c=feed.Body;

with

comment.FeedCommentBody__c=feed.CommentBody;

Note: You are referring FeedItem  in the link you posted, but I see in your code you have FeedComment

Please refer link below 

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedcomment.htm

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya


 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi Matt Lieber,

replace you code 

comment.FeedCommentBody__c=feed.Body;

with

comment.FeedCommentBody__c=feed.CommentBody;

Note: You are referring FeedItem  in the link you posted, but I see in your code you have FeedComment

Please refer link below 

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedcomment.htm

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya


 
This was selected as the best answer
Shreyas Shah 9Shreyas Shah 9

Hi,
Yes.
 'Body' is a standard field on FeedItem. 

But in above code you triggered on "feedcomment" Object So need to use  "CommentBody" field.

DeepthiDeepthi (Salesforce Developers) 
Hi Matt,

As Sandhya referred, CommentBody  is a standard field of "FeedComment" object and Body  is a standard field of "FeedItem" object.
And in your trigger, you are referring to the FeedComment object hence, replace your code "feed.CommentBody"
Kindly check the below links for more details:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm 

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedcomment.htm 

Hope this helps you!
Best Regards,
Deepthi