...
To create one issue each for the users jdoe,tblack and dcharlie
and assign the newly created issues to the respective user
In the Iterator section input
Code Block language js jdoe,tblack,dcharlie
Go to
Set fields of new issue
sectionUnder
Additional fields
select "Assignee"Click on
Add
Select
Set field value to
option from the drop-downInput this template:
Code Block language js {{it}}
...
In the Iterator section input
Code Block language js {{ issue.fields["Multi user picker"] | join(",","accountId") }}
To assign the newly created issues to the respective user:
Go to
Set fields of new issue
sectionUnder
Additional fields
select "Assignee"Click on
Add
Select
Set field value to
option from the drop-downInput this template:
Code Block language js {{it}}
...
Instead of a list of values or an array of values as in the examples above, each value in the list can be an arbitrary JavaScript object with multiple values and each object will be available through the it
variable in the rest of the post-function configuration. For example, if the iterator returns the following:
...
Info | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a sequence
Now when you trigger the transition "Clone now" the Parent and its subtasks are cloned to the new project. |
Cloning an issue and its subtasks
Using the Sequence of post-function post-function you can clone an issue and its subtasks too. Let's assume on the trigger of the transition "Clone now" you want to clone a Parent and its Subtasks to a different project.
Info | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Create a sequence
Now when you trigger the transition "Clone now" the Parent and its subtasks are cloned to the new project. |
Link newly created issues
...
Code Block | ||
---|---|---|
| ||
[ { "summary":"A first issue" }, { "summary":"A second issue" }, { "summary":"A third issue" } ] |
Using the newIssueKeys
variable
This is a very generic approach in which you can use the newIssueKeys
global variable that exposes the array of the issue keys of the issues already created by the post-function during previous iterations. For example, if your iterator value is an array of three values (three issues will be created), during the creation of the third issue, newIssueKeys
global variable array holds the first two issue keys. This way, you can add in your Iterator objects information about the links to create between issues.
...
Add linking information to the above array as shown below with the "Iterator returns JSON" option selected, where
linkTo: represents an index pointing to the issue to be linked to.
0
for the first issue,1
for the second issue and so on.linkTypeName: represents the name of the link type to be created, like,
Blocks
direction: represents the direction to be linked to, like,
outward
Code Block [ { "summary":"A first issue" }, { "summary":"A second issue", "linkTo": 0, "linkTypeName": "Blocks", "direction": "inward" }, { "summary":"A third issue", "linkTo": 1, "linkTypeName": "Blocks", "direction": "outward" } ]
Under the "Set fields of new issue" select
Linked Issues
fieldSelect "Set field value to" in the drop-down and input the following template:
Code Block language js [ {% if it.linkTo != null %} { "type": {"name":"{{it.linkTypeName}}"}, "{{it.direction}}Issue": {"key":"{{newIssueKeys[it.linkTo]}}"} } {% endif %} ]
...
To avoid creating a second issue when the transition is run a second time you can use the jmwe.last.issue.created
(see here for more information) property of the issue to check that there is no issue created already by the post-function. Select the conditional execution section and input the template:
...
In the first example, add a condition in the conditional execution template to check that the main issue (issue from which multiples issues are created) is not a subtask.
Code Block language js {{ not issue.fields.issuetype.subtask }}
In the second example, identify the main issue by its issue type as follows.
Code Block language js {{ issue.fields.issuetype.name == "Story" }}
The best is to use the
jmwe-created-from
property of the issue; Using this approach check that the issue is not created from another issue.Code Block language js {{ issue | issueProperty("jmwe-created-from") == null }}
...