Hi,
I'm looking to use the Create Issue post function to create an issue and all its subtasks in another project. I assumed this should split between two post functions but i'm struggling to iterate through the current issue's subtasks to get all their data and create them in the other project.
Hi @Ahmad Sidawi
first of all, the two Create Issue(s) post-function must be in a Sequence of Post functions post function, unless you're using them in an Action (Shared, Scheduled or Event-based) to ensure the post-functions run one after the other (Jira doesn't guarantee that third-party post functions on issue transitions run sequentially).
Then, in the second post-function that clones the sub-tasks :
Let's start by setting our Iterator, then add the fields we want to grab. To begin, set this as your iterator, and test it against an issue that has Subtasks:
{{issue.fields.subtasks | dump(2) }}
You should see a JSON output of all of the subtasks of the issue you test against. Make sure you check the "Iterator returns JSON" box. Now we can set Summary to:
{{ it.fields.summary }}
and Priority to:
{{ it.fields.priority.name }}
Unfortunately, this object only returns a subset of available fields for an issue, so it own't work for every field you may want to copy. You may be able to use the "subtasks" filter to build an array of each of the fields you want, but I'm not sure.
Cheers,Evn
Worked! I replaced the ContextIssue for Parent with a SearchIssues as the ContextIssue didn't work. One more thing, is it possible to auto link the generated subtasks to the original subtask? So if the Parent ticket is 'blocked by' or 'addressed by', can the subtasks have that link to each other rather than the Parent? (this could be done through a Jira automation or a separate action but just wondering if possible through the CreateIssue action)
You should be able to achieve this by adding the "Linked Issues" field to the "Set specific fields of new issue(s)" section, like this:
Note that you'll need to update the link type name (careful, it's the link type name as it appears on the "Issue Linking" Jira admin page, not the link type direction). You might also need to replace "outwardIssue" with "inwardIssue" depending on the direction of the link to create between the two subtasks.
@David Fischer
Last question, when iterating through the subtasks to create, can I filter out subtasks in a statusCategory of done? I've tried using filter but to no avail yet
It looks like you're new here. Sign in or register to get started.