Date: Fri, 29 Mar 2024 11:39:57 +0000 (UTC) Message-ID: <562275067.19.1711712397333@ac354d91bd8a> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_18_1583585235.1711712397332" ------=_Part_18_1583585235.1711712397332 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
A workflow post-function that creates one or more new issue(s). The spec= ifications of the issue(s) to be created can be customized using the option= s provided.To add the 'Create issue' post-function to a transition<= /strong>:
Click Edit for the workflow that has the tran= sition you wish to add the post-function on.
In the Workflow Designer, select the transition.
Click Post Functions
in the properties panel.
Click Add
post function
.
Select Create issue(s)
from the list of post-func=
tions.
Click Add
to navigate to the Create issue=
(s) post-function screen where you can add configuration details t=
o the post-function. Click here to know more.
Click Add
to add the post-function to the transition.
After adding, move the post-function to the appropriate position accordi= ng to Placing post-function= s in a transition document.
Click here for a use cas= e of this post-function.
Known issues common to all post-functions:
Troubleshooting this post-function configuration: <= /em>In case the post-function does not work as expected these are the thing= s to look out for
Use cases and additional information
Configure the following details in the Create issue(s) post-func= tion screen:
Specify the target project and issue type.
Project: Set the project where you wan= t the new issue(s) to be created. Select one of the following to set the pr= oject as:
Same as the current issue: The same= project as the current issue.
Calculated: A project whose key is the value returned f= rom the Nunjucks template.
Projects: A project selected from the list.
Issue type: Select the issue type to be assigned t=
o the newly created issue.
When the issue type is Sub-task
, specify its parent issue=
in the Parent issue
field.
Current issue: The current issue will be the parent of the newly c=
reated issue.
Another issue: An issue whose key is the value ret= urned from the provided Nunjucks template, will be the parent of the newly = created issue.
When the issue type is Calcula=
ted
, you can type the issue type name or ID or a Nunjucks template retu=
rning a valid issue type name or ID in the Nunjucks template editor.
When the issue type is:
Epic
- set the Epic Name
f=
ield with a value using the Set fields of new issue&n=
bsp;option (explained below).
Story
- you might want to add the newly created story to an=
Epic. In this case, you should add the Epic link
fi=
eld with the key of the Epic as the value in the Set fields of=
new issue option (explained below)
When the Project is Same as the current project
or Ca=
lculated
the list of issue types contains all the issue types configured in your Jira instance, even though some of them mi=
ght not apply to that project.
Select a link type from drop-down to link the newly created issue to the= current issue. The default value is "is not linked to", which will no= t create any link.
Specify the current issue fields to be copied to the new issue(s).
Mode
Only copy or set fields listed below: If you select thi= s option, only fields specified explicitly under the Set specific f= ields of new issue section will be copied or set on the new issue.=
Copy all fields that appear on the Create screen of the issue ty= pe to create, in the target project: If you select this option, al= l fields that appear on the Create screen of the issue being created will a= utomatically be copied from the current issue to the new issue, as if they = were being entered by the user on the Create screen.
= li>Copy all fields: If you select this option, all fields = that have a value on the current issue and that apply to the issue being cr= eated will be copied from the current issue to the new issue.
Regardless of the selected option, if you add a field under the = Set specific fields of new issue section, it will always be copied= or set accordingly.
Set the field values of the newly created issue, regardless of the optio= n selected under Copy fields to new issue(s).
Summary: This added by default since it is required for= any issue type.
Add field: Select a field from the drop down and click =
Add
to add the respective field. Set the field using one of th=
e following options:
Copy value from current issue: Copies the field value(s= ) from the current issue.
Set to other field of current issue: Sets the fiel= d to the value of another field of the current issue. Say, to set the Repor= ter of the current issue as the Assignee of the newly created issues.
= li>Set field value to: Set the field to a specific va=
lue, which can include Nunjucks annotations.
For example: To set the Fix Version/s to 2.0, you can specify 2.=
0
in the value box.
Click the Remove
icon to remove the respective field.
Note that you can copy the issue links of the current issue to the newly=
created issue by setting the Linked Issues
field to=
copy the values from the current issue.
Ignore fields that don't apply to the new issue: If you= add a custom field(s) above that do not apply to the issue being created (because it i= s configured to apply only to certain issue types or projects), the post-fu= nction will fail (so you can pinpoint the problem). Select this option to i= gnore this error instead, which can be useful if you are creating multiple = issues in different projects or of different types.
Use this option to copy the existing comments/newly added comments of th= e current issue to the newly created issue.
Don't copy any comment to the newly created issue(s): T= his is the default option. Select this option to not copy comments to the n= ewly created issue
Copy the transition comment to the newly created issue(s): Select this option to copy the comment added on the transition screen t= o the newly created issue.
Copy all comments from the current issue to the newly created is= sue(s): Select this option to copy all the comments on the current= issue to the newly created issue.
The restricted comments to which the =E2=80=9CRun as user=E2=80=9D does = not have permissions are not copied to the newly created issue.
Add a comment to the current issue: Select this option = to add a comment to the current issue.
Comment (displayed only when the previous option is sel=
ected): Add any simple text, e.g. This is a comment.
=
You can also use Nunjucks&nb=
sp;annotations in the comment using variables. To find out mor=
e about the variables, see How to insert information using Nunjucks annotations.
Note that the newly created issue's key is available in the Nunjuck=
s context as the newIssueKey
variable.
For example : Issue {{newIssueKey}} has been created.
<=
/p>
Comment visibility
Restrict to Group: Select a group from the drop-down to= restrict the visibility of the comment to the members of the specified gro= up. For no restriction, leave the field blank.
Restrict to Project Role: Select a project role from th= e drop-down to restrict the visibility of the comment to the users with sel= ected project role. For no restriction, leave the field blank.
Restrict to Internal (Jira Service Desk only): Select t= his option to restrict the visibility of the comment to the Service Desk Ag= ents and Collaborators.
Create comment as
Create comment as current user: Select this option to s= et the current user as the author of the comment created. This is the = default value.
Create comment as add-on user: Select this option = to set the add-on user as the author of the comment created.
Create comment as this user: Select this option to= enable the associated drop-down. Select a user from the drop-down to set t= he specified user as the author of the comment created.
Use this section to create multiple issues based on the settings you pro= vide.
Create multiple issues: Select this option to create mu= ltiple issues at once. Provide an iterator script to con= trol the number issues to be created. By default, the Create issue<= /strong> post-function creates one new issue.
Iterator (displayed only when the previous option is se= lected): Enter a Nunjucks template that must return a comma-separated = list of values to iterate on. This can be either a comma-separated list of = Strings, or a JSON array only if you check the "Iterator returns JSON"= option. The post-function iterates over the list and creates one new issue= per value. If configured, a new comment is also added to the current issue= for each new issue created.
Template returning a comma-separated list of Strings
If the iteration template returns: jdoe,tblack
th=
en one issue will be created with the it
variable co=
ntaining"jdoe"
and then another with the it variable containing
"tblack"
. And if, in the configuration =
of the post-function, you are setting the "Assignee" field of the newly cre=
ated issue to the following Nunjucks Template: {{it}} then the fi=
rst issue will be assigned to jdoe
and the second to tbl=
ack
. And when you test the template the tester will return
Examples:
Bug,Task
{{issue.fields["Multi-user Picker field"] | join(",","accountId")}=
}
will create one issue per user in the Multi-user Picker field=
.
{{range(1,5)}}
will create 4 issues, with the it&=
nbsp;
variable containing numbers from 1 to 4.
Template returning a JSON array
If the iteration template returns a JSON =
array: [ {"assignee":"jdoe", "summary":"Issue for John Doe"} , {=
"assignee":"tblack", "summary":"Issue for Tim Black"} ]
and you=
select the "Iterator returns JSON" option, then you'll be able to use=
{{it.assignee}}
as the value for the Assignee field=
, and {{it.summary}}
as the value for the Summary fi=
eld.
Examples:
{{"jira-administrators" | groupMembers | dump }}
with "Iter=
ator returns JSON" option selected will create one issue per user in t=
he 'jira-administrators' group
{{issue.fields["Multi-select field"] | dump }}
w=
ith "Iterator returns JSON" option selected will create one issue per =
selected option in the Multi-select field
Run a Nunjucks script after the issue(s) are created: S= elect this option to run a Nunjucks script after each new issue is created = to make additional changes to the issue, such as adding a remote link or ca= lling an external API. In scenarios where you use this script for setting i= ssue field values, the respective value set during issue creation is overwr= itten.
Script: Enter the Nunjucks script as needed.
During the execution of the script, the newIssueKey
&nb=
sp;variable points to the newly created issue.
Automatically navigate to the newly created issue: Sele= ct this option to automatically navigate the user to the new issue created = at the end of the transition. This is applicable only when the transit= ion is triggered from the View Issue page.
This requires the "Enable View Issue Screen Actions" option on the = JMWE Configuration page to be enab= led.
After the issue creation, the post-function stores
the key of the issue it creates in an issue property =
jmwe.last.issue.created
of the current issue (the one on =
which the post-function runs) You can retrieve it later using the&nbs=
p;issueProperty
Nunjucks filter. This can be used in othe=
r post-functions to refer to the last issue created by the Create issue pos=
t-function. If multiple issues are created, then the issue property refers =
to the last created issue.
the key of the original issue in an issue property issueProperty
Nunjucks filter=
. This can be used in other post-functions to refer to the issue from which=
the current issue was created using the Create issue post-function. You ca=
n also, use it in the JQL searches using the syntax: issue.=
property[jmwe-created-from].key =3D TEST-123
However, there are caveats you need to be aware of:
the post-function that reads this property needs to run after= em> the Create Issue post-function finishes. You can ensure it by = ;adding= a delay.
If two users simultaneously run a transition on the same issue<=
/em> that creates a new issue, only the last issue created will be ava=
ilable in the jmwe.last.issue.created
property. So t=
his makes the feature unreliable if you're using the Create Issue post-func=
tion on multiple transitions of the same workflow.
Select one of the following to set the creator of the issue:
Run as current user
Run as add-on user
Run as this user: Select this option t= o enable the associated drop-down. Select a user from the drop-down to set = the specified user as the creator new issue.
Run this post-function only if a condition is verified:= Select this option to execute this post-function based on the result of a = Nunjucks template. See Conditional executio= n.
Condition (displayed only when the previous option is s= elected): Enter the Nunjucks template as needed.
Post functions are provided with an option to delay their execution= . You need to select the number of seconds to wait until the post-function is run, a default of 1 sec to a&n= bsp;maximum of 20 seconds.
Workflows that depend on post functions being executed in a specifi= c order fail due to the asynchronous nature of the Connect pos= t-functions in Jira Cloud. One of the workarounds is to delay the exec= ution of the post-functions and thereby create a more predictable execution= order. For example, on the approval of a Story you want to create sub-task= s and immediately transition them; in this case, you will have to delay the= execution of the Transition Linked Issues post-function, so that the sub-t= asks are created before they are transitioned. See the use case belo= w.
It is recommended to use the Sequence= of post-functions post-function or Shared Action post-function post-function to run a list of post-functi= ons in a sequence instead of applying a delay.
On the creation of a Bug, assign it to a memb= er of the QA team and then add the Assignee to the Watchers.
On the approval of a Story, create subta= sks for Development and QA, and transition them to In Progress st= atus.
JMWE shows an error message on the issue view if any error occurs during= the execution of the post-function. This message is displayed only if = the current user is a Jira administrator.
A typical use case for this workflow is to create one or more issues dur= ing a transition. Consider a use case where you want to create a documentat= ion ticket only if "Needed" is selected in the "Documentation ticket" check= boxes field. To configure this:
Add the Create issue post-function to the transition on whose t= rigger you want to create a documentation ticket
Select Documentation
from the Project
field.=
p>
Select Document
from the Issue type
field.
Select caused by
in the Link to new issue
sect=
ion.
Add an appropriate Summary (such as Release documentation
)<=
/p>
Select the conditional execution and write the following template
{{ issu= e.fields["Documentation ticket"] | find({"value":"Needed"}) !=3D null }}