Post

2 followers Follow
0
Avatar

Download Documents of the task in a nested folder Project1/Task1/ all Documents

Hello Team,

I had put this on support task and they have requested me to put it on developer forum.

Using Documents entity and Download service I am able to get the documents downloaded.
However what I need is to save it in a folder structure as Projects/Task/Documents

For this I want to 1st load the projects and then its all the tasks of a project and then download all the documents of a respective task.

I am not able to find out the relationship between the Entities Project, Tasks and Document since the metadata/describeEntityRelations is not working. Please see the attached image.

Could you help me out here by and provide me a way to get the documents saved in a folder having structure as Projects/Task/Documents
Project1/Task1/ all Documents
Project1/Task2/ all Documents

Thanks,

Omair

Omair Nalkhande Answered

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Omair,

I believe the following CZQL provides all work items in a particular project (change 4tff5jai186bedzidpuk08dvm1 to the external(API) id of your project) with its attached documents:

select name, parent , (select name from Documents) from workitem where project='/project/4tff5jai186bedzidpuk08dvm1'

By the way, you can use describeMetadata with the flag relations as an alternative to describeEntityRelations. Check the REST API reference for more information

Hope this helps,

Ophir

 

 

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Thanks For the reply Ophir.

I tried your solution but there are some task which has subtasks and their comments have attachments too. The CZQL that you suggested is only providing with task's documents from description and not from the comments or the post.

 

Could you please suggest what should I do here?

Thanks.

Omair Nalkhande 0 votes
Comment actions Permalink
0
Avatar

Hi Omair,

I don't know what you mean 'comments'?

Anyway, you can retrieve the work items' posts with the same technique
(e.g. select name, parent ,  (select createdby  from Discussions), (select name from Documents) from workitem where project='/project/4tff5jai186bedzidpuk08dvm1') and then query the discussions for documents in turn.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink