Post

2 followers Follow
0
Avatar

Get Discussion Posts On Issues with REST API

I am trying to do a data query through the REST API to get discussions on cases.

 

{paging: {limit:1000,from:1000},q:'Select Container,AttachmentsCount,Body from DiscussionMessage'}

This is giving us only replies from each post, not the main post itself.  Also I would like to filter out discussions that are not part of a Case.

What is the proper query to retrieve what I need?

Thanks,

Josh

 

 

Joshua Smith Answered

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Joshua,

First, I believe you're getting only replies because of the paging clause. The code you provided here tries to retrieve the second 'page' of 1,000 messages. Try from:0 instead of from:1000, to start with. The paging property of the result, particularly hasMore property will tell you if you need to issue another query (and also the right from value). 

Second, you can filter the Container with an in clause, for example: 

select body,AttachmentsCount, container.name  from discussionmessage where container in (select sysid from case).

Pay attention to the performance of this, as retrieving all Cases for your account to filter the discussions may take longer than retrieving all discussion messages and filtering the results in your application (specifically by the identifier of the container).

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Ophir,

Can you please help me with getting the id list of attachments on a discussion post?  For cases I am doing this:

Select AttachmentsCount,(Select Name from Documents) from Case

But including "(Select Name from Documents)" for discussion posts doesn't return anything for attachments:

Select Container.Name, AttachmentsCount ,Body,EntityType,post,(select name from documents) from DiscussionMessage

Is there another entity I need to query to get the attachments for discussion messages?

Joshua Smith 0 votes
Comment actions Permalink