Johan
Johan

Reputation: 1

How to export work item in workflow of youtrack

I'm trying to export reported times by the use of workflows. I have managed to make a workflow that sends a http request on time change

rule Post work items
when issue.Spent time.changed {
    var url="https://myserver/jsp/testReceiveOfHours.jsp?issueid="+issue.getId();
    var payload="{\n\t\"payload\": {\n\t\t\"json\": true\n\t}\n}";
    doHttpPost(url,payload);
}

This work, I get a trigger that some work hour is changed but I don't know which. But at the other server i made a jsp that got back to youtrack via the REST API to fetch all work items of that issue. That works except that it doesn't look like the most resent changed work item is saved to the database before I do the fetch, so I don't get the work item I'm looking for only older. So before I get into make some sort of delay/queue (or something). Is there a way to add the changed work item json (same as is returned from //youtrackserver/rest/issue/issueid/timetracking/workitem/workitemid) to the payload of the doHttpPost? If not json maybe the data in some other form?

Upvotes: 0

Views: 783

Answers (1)

Mariya Davydova
Mariya Davydova

Reputation: 1393

In Workflow API in YouTrack before 2017.2 there was no way to get work items from an issue. In YouTrack 2017.2 new property appears (issue.workItems), so that you can get added workitems by issue.workItems.added.

You can also give a try to an experimental Workflow API (which is JS-based and supported with an in-browser editor).

API for work items is not described in documentation for the old API, but you can find it in experimental API reference: BaseWorkItem, IssueWorkItem, Issue.

Upvotes: 1

Related Questions