Post

2 followers Follow
1
Avatar

Pull all Posts and Replies from all Request Cases using REST API

I have been tasked with pulling all Posts and Replies from all Request Cases to include the ID of the Case, the message text, the User that posted each of the Posts and Replies and the time of the Discussion Message. 
I have been struggling to get an entity query to bring back this data and figured it can't hurt to see if any of you could help me out. 
Any advice would be greatly appreciated. 
Thanks, 
Dan

Kelly, Daniel Answered

Official comment

Avatar

Hi Kelly,

My apologies for the late response.

Try the following request:

POST /data/entityQuery
{
"typeName": "DiscussionMessage",
"fields": [ "Text","Container","Post", "CreatedBy", "CreatedOn" ],
"orders": [ { "fieldName": "CreatedOn", "order": "Descending" } ],
"where" : {
"leftExpression": { "fieldName": "Container" },
"operator": "In",
"rightExpression": {
"query": {
"_type": "entityQuery",
"typeName": "EnhancementRequest"
}
}
}
}

Brief explanation:

  • The DiscussionMessage is the base class for DiscussionPost and DiscussionReply classes.
  • The Container field is the reference to the entity. It may be Case, WorkItem, Project, EnhancementRequest or something else.
  • The Post field is the reference to the initial DiscussionPost. You need this for replies.
  • I filtered all DiscussionMessages using the inner query in the "where" clause.

Let me know if it helps.

Regards.

Alex Broitman
Comment actions Permalink

Please sign in to leave a comment.

2 comments

1
Avatar

Alex,

That did the trick.  And taught me a new trick.

Thanks,

Kelly, Daniel 1 vote
Comment actions Permalink