soql select individual CaseComment with all its FeedComments

假如想象 提交于 2021-01-28 17:49:47

问题


I am trying to select all comments ,feeds and feedcomments for an individual case. The hierarchy is like

Case
    |
     CaseComment
                |
                 FeedComments(commnets or feeds under a CaseComment)

I could not find any relation between CaseComments and FeedComments nor CaseComments and CaseFeeds. How can I select all together in a soql or individual soqls which relates Case, CaseComment,CaseFeed,FeedComment?

enter image description here


回答1:


EDIT

The query you've included in the comment looks good. I'd write it as something like that:

SELECT Id, Body, ParentId, Parent.CaseNumber, CreatedDate,
    (SELECT Id, CommentBody, CommentType FROM FeedComments)
FROM CaseFeed
ORDER BY Parent.CaseNumber, CreatedDate

enter image description here

(this is sample output rendered in Real Force Explorer, a pretty neat tool)

If I'll click into the "2 records" bit I can drill down to the fields selected from FeedComment for "this" CaseFeed:

enter image description here

If your query renders differently for you (some stuff is blank) - maybe try this different editor or even go to https://workbench.developerforce.com

If only some comments contain text - they might be uploaded images for example - filter them by CommentType = 'TextComment'?


ORIGINAL

FeedComments(commnets or feeds under a CaseComment)

No, not really. FeedComment is a Chatter table that can link to many objects but CaseComment is not one of them.

enter image description here

Maybe study the Chatter Entity Relationship Diagram?

Anyway - relationship to feed* objects doesn't have a nice name exposed so we can't query it all in one go:

enter image description here

I think you'll need something like this:

SELECT Id, CaseNumber,
    (SELECT Id, CommentBody FROM CaseComments),
    (SELECT Id, Body FROM Feeds)
FROM Case

SELECT Id, FeedItemId, ParentId, CommentBody
FROM FeedComment
WHERE ParentId = :caseIdHere


来源:https://stackoverflow.com/questions/20985609/soql-select-individual-casecomment-with-all-its-feedcomments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!