API Request Help: How to get Timelog data, per month, per folder.
Hello!
I am building a program to work around an issue as a safety net for our transition to Wrike. We've already signed a contract to switch to Wrike, and we love working in the app so far, but the reporting is desperately lacking for us. We are aiming to transition off of our current time tracking software in favor of Wrike, but cannot get the data we need in one report yet. So my program is intended to get that data coalesced into one nice spreadsheet.
Important note: I'm going to show an example structure in app, however I'm asking about the api. The app pictures are for visual reference and setup of the problem/goal. Unfortunately custom fields cannot be brought into reports right now. I've confirmed with 4 different people at Wrike, through 3 demonstrations that this is not possible in app. A request for this feature is in with at least 2 of those people. I am not looking for an in app solution because I know with 99.99% certainty that at the time of writing it does not exist. I am asking about how to get better data from API calls.
The short setup is this:
We have a space, that space has folders to denote clients we have, in each folder is a project for the contracts, and in those contract projects are subprojects for the work (web builds, logos, etc), those projects have tasks, those tasks are where people log their time.
Our business structure has an hourly bill rate for each contract. We need to know at the end of the month how many hours were worked on a contract that month, and the bill rate.
This is an example of our structure for visual reference. What you can see here is the total time spent, not the time spent for the month. This would be perfect if I could only show time spent for the month in this view but that is not possible. Hours are rolled up, bill rate is manual, which is fine.
Here is what we get if I do a timelog view for monthly hours (Reports generate the same view but if needed I can go get a screenshot there too). Note that this doesn't roll up the hours to the parent project, and you cannot get the custom "Bill Rate" field:
Here's the gear options just to show that it's not in there on the timelog view:
Currently my program does the following (this is a NodeJs + ExpressJs program if it helps):
- Get all of the timelogs for the month from : /api/v4/timelogs?trackedDate={"start":"2021-04-1","end":"2021-04-30"} (dates as example)
- I have to pull all the task ids off of these entries then put together sets of requests of 100 for the task details (id limit).
- I have to get a list of all tasks to build a list of task ids (this will come in to play later)
- Then I have to request the individual tasks from : /api/v4/tasks/[id's up to 100]
- Then I have to process those tasks to get their parents, I have use the big all task ids array to make sure that I don't build requests to /folders/ with a task id, as this breaks things.
- If I have sub tasks (we shouldn't per policy, which is only policy because of this reporting pain point) I'll have to process those to get parents until I have the project/folder.
- Once I have the list of all the parent Id's I have to go get those for the details and parents again building requests to make sure I limit to 100 ids from : /api/v4/folders/[id's up to 100]
- I have to keep looping over these parents until I am requesting the space as the parent, when I can mark the process done.
- While getting this information I do some work to re piece together the structure so that I can roll up bill rates, and hours, and calculate bill amounts per client (folder)
My program currently does this and works (for now) but due to the structure of not being able to treat this data like a database (I cant just do joins per request) it is fragile. If someone makes and tracks time to a sub task currently, it will at best be ignored, at worst break the script. I can work around that, but it will add even more API calls.
There's gotta be a better way to get this information from the API. This is currently a minimum of 7 asynchronous requests, and I only have 2 folders, 2 contracts, and 4 projects... Just getting this information is a 3~6 second process, meaning that when this scales up and our whole process and projects are in here it will almost certainly time out, or require extra steps. Just to get an Hours spent per project per month, with the custom field of bill rate, rolled up to the folder or even parent project level.
Please help 😞! What we thought we could do in Wrike is not looking feasible as is. Is there a better way to get time logged to a project level? Any step I can take out of the above process is a MASSIVE win for durability and usage for me.
I'm not seeing/sure if there's a limit on returned data also. If I request all Tasks/Folders/Timelogs, do I get all of them, or is there a limit on what is returned. I suppose if I could just get all of these things I could build my own database. I'd say that's a lot of work, but I'm 24 hours deep on this API, and this is a make or break kind of problem so I'm willing to do all the work.
Consider this also a request for the Wrike app to allow custom fields in timelog based reports for projects and better report rollup, but I need this work around until/if that happens.
Thanks,
Grayson Lorenz
Side note, italics in these posts don't seem to be working. This text should be italic.
Hi Grayson Lorenz, thank you for the detailed post. I've raised the ticket with our Support team so that they could advise you. I can see that they have reached out to you via email.
p.s. Thank you for flagging the italic text function issue it should be solved soon.
Please let me know if I can help with anything else 🙋🏻♀️