Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

A workflow post-function that creates one or more new issue(s). The specifications of the issue(s) to be created can be customized using the options provided.

To add the 'Create issue' post-function to a transition: 

  1. Click Edit for the workflow that has the transition you wish to add the post-function on.

  2. In the Workflow Designer, select the transition.

  3. Click on Click Post Functions Functionsin the properties panel.

  4. Click on Click Add post function.Select .

  5. Select Create issue(s) from the list of post-functions.

  6. Click Add to navigate to the Create issue(s)  from the list of post-functions.

  7. Image Removed
  8. Click on Add to add the post-function to the transition.

See
  1. post-function screen where you can add configuration details to the post-function. Click here to know more.

  2. Click Add to add the post-function to the transition.

After adding, move the post-function to the appropriate position according to Placing post-functions in a transition document.

Click here for a use case for of this post-function.

Known issues common to all post-functions:

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
sorttitle
showSpacefalse
typepage
labelskb-troubleshooting-article
cqllabel = "common-issue" and type = "page" and space = "JMWEC"

Troubleshooting this post-function configuration: In case the post-function does not work as expected these are the things to look out for

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
sorttitle
showSpacefalse
typepage
labelskb-troubleshooting-article
cqllabel in ( "placing-postfunctions" , "troubleshooting" ) and type = "page" and space = "JMWEC"

Use cases and additional information

Info

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. 

When you add this post-function to a transition and trigger the transition, the add-on creates one or more new issue(s).

Options

Create new issue

Project : Project in which the new issue should be created.

Configuration details

Image Added

Configure the following details in the Create issue(s) post-function screen:

Destination

Specify the target project and issue type.

  • Project:Set the project where you want the new issue(s) to be created. Select one of the following to set the project as:

    • Same as the current issue:  Creates an issue in the The same project as the current issue.

    • Calculated: Creates an issue in a A project whose key is the value returned from the Nunjucks template.

    • Projects: Creates an issue in the A project selected from the list of projects.

  • Issue type: Issue type of  Select the issue type to be assigned to 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 created issue.

    • Another issue: An  An issue whose key is the value returned from the provided Nunjucks template, will be the parent of the newly created issue.

When the issue type is Calculated, you can type the issue type name or ID or a Nunjucks template returning a valid issue type name or ID in the Nunjucks template editor.

Note that when

When the issue type is:

  • Epic

, you should set the 
  • - set the Epic Name field with a value using the Set fields of new issue option (explained below).

  • Story

,
  • - you might want to add the newly created story to an Epic. In

that
  • this case, you should add the Epic link field with the key of the Epic as the value in the Set fields of new issue option (explained below)

Note

When the Project is Same as the current project or Calculated the list of issue types contains all the issue types configured in your Jira instance, even though some of them might not apply to that project.

Link to new issue

Links

Select a link type from drop-down to link the newly created issue to the current issue

, with a link type selected from the list of link types

. The default value is "is not linked to", which will not create any link.

Copy fields to new issue(s)

Specifies which fields of

Specify the current issue

should

fields to be copied to the new issue(s)

:

.

Mode

  • Only copy or set fields listed below: if If you select this option, only fields specified explicitly under the Set specific fields 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 type to create, in the target project: if If you select this option, all fields that appear on the Create screen of the issue being created will automatically be copied from the current issue to the new issue, as if they were being input entered by the user on the Create screen.

  • Copy all fields: if If you select this option, all fields that have a value on the current issue and that apply to the issue being created will be copied from the current issue to the new issue.

Note that, regardless

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 specific fields of new issue 

Sets

Set the field values of the newly created issue, regardless of the option selected under Copy fields to new issue(s).

The

  • Summary

field is
  • : This added by default since it is required for any issue type.

  • To add a Add field:  Select Select a field from the list of fields drop down and click onAdd.

  • To Remove an added field : Click on Remove to remove a field.

  • To Set a field value to add the respective field. Set the field using one of the 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 field to the value of another field of the current issue. Say, to set the Reporter of the current issue as the Assignee of the newly created issues.

    • Set field value to: You can set  Set the field to a specific value, which can include Nunjucks annotations.
      For example: To set the Fix Version/s to 2.0, you can specify 2.0 in the value boxthe value box.

  • Click the Remove icon to remove the respective field.

Note

Note that you can now 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 is configured to apply only to certain issue types or projects), the post-function will fail (so you can pinpoint the problem).

If you want
  • Select this option to ignore this error instead, which can be useful if you are creating multiple issues in different projects or of different types

, select this option
  • .

Copy comments to new issue(s)

Using Use this option you can to copy the existing comments/newly added comments of the current issue to the newly created issue.

  • Don't copy any comment to the newly created issue(s): This is the default option. Select this option to not copy comments to the newly created issue

  • Copy the transition comment to the newly created issue(s): Select this option to copy the comment added on the transition screen to the newly created issue.

  • Copy all comments from the current issue to the newly created issue(s): Select this option to copy all the comments on the current issue to the newly created issue.

Note that

The restricted comments to which the “Run as user” does not have permissions

will

are not

be

copied to the newly created issue.

Add

comment

Copy the transition comment to the newly created issue(s)

Copies the comment added on the transition screen, if any, to the newly created issue(s)

a comment to current issue

  • Add a comment to the current issue

Adds
  • : Select this option to add a comment to the current issue.

 The Comment can be

Note that the newly created issue's key is available in the Nunjucks context as the newIssueKey variable. 

For example : Issue {{newIssueKey}} has been created.

  • Comment visibility

    • Restrict to Group: Restricts the visibility of the comment to a specified group. When you select a valid group name in the Restrict to Group field, the comment will be visible only Select a group from the drop-down to restrict the visibility of the comment to the members of the specified group. For no restriction, leave the field blank.

    • Restrict to Project Role: Restricts the visibility of the comment to a selected project role. When you select a Select a project role from the drop-down Restrict to Project Role field, the comment will be visible only to the members of the down to restrict the visibility of the comment to the users with selected project role. For no restriction, leave the field blank.

    • Restrict to Internal (Jira Service Desk only): Restricts Select this option to restrict the visibility of the comment to the Service Desk Agents and Collaborators onlyCollaborators.

  • Create comment as

    • Create comment as current user : The : Select this option to set the current user will be as the author of the comment created. This is the default value.

    • Create comment as add-on user: The  Select this option to set the add-on user will be as the author of the comment created.

    • Create comment as this user: Any user selected in this field will be the author of the comment created.

Multiple Issue Creation

By default, the Create issue post-function will create a single new issue, according to the settings above. If you want to create multiple issues at the same time, check the Create multiple issues option. You will then need to provide an iterator script that will control how many issues are created.

Iterator template

The iterator template is a Nunjucks template that must return a comma-separated list of values on which to iterate. This can be either
    •  Select this option to enable the associated drop-down. Select a user from the drop-down to set the specified user as the author of the comment created.

Multiple issue creation

Use this section to create multiple issues based on the settings you provide.

  • Create multiple issues: Select this option to create multiple issues at once. Provide an iterator script to control the number issues to be created. By default, the Create issue post-function creates one new issue.

  • Iterator (displayed only when the previous option is selected): 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, or a JSON array only if you check the "Iterator returns JSON" option below. The post-function will iterate over the list and create one new issue per value. If configured, a new comment will also be 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 then one issue will be created with the it variable containing"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 created issue to the following Nunjucks Template: {{it}} then the first issue will be assigned to jdoe and the second to tblack. And when you test the template the tester will return jdoe.

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 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 field.

Examples

  • {{"jira-administrators" | groupMembers | dump }} with "Iterator returns JSON" option selected will create one issue per user in the 'jira-administrators' group

  • {{issue.fields["Multi-select field"]  | dump }} with "Iterator returns JSON" option selected will create one issue per selected option in the Multi-select field

After issue creation

On selecting "Automatically navigate to the newly created issue" option, the user will automatically be navigated

If the iteration template returns: jdoe,tblack then one issue will be created with the it variable containing"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 created issue to the following Nunjucks Template: {{it}} then the first issue will be assigned to jdoe and the second to tblack. And when you test the template the tester will return jdoe.

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 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 field.

Examples:

  • {{"jira-administrators" | groupMembers | dump }} with "Iterator returns JSON" option selected will create one issue per user in the 'jira-administrators' group

  • {{issue.fields["Multi-select field"]  | dump }} with "Iterator returns JSON" option selected will create one issue per selected option in the Multi-select field

Post-creation script

  • Run a Nunjucks script after the issue(s) are created: Select 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 calling an external API. In scenarios where you use this script for setting issue field values, the respective value set during issue creation is overwritten.

  • Script: Enter the Nunjucks script as needed.

During the execution of the script, the newIssueKey variable points to the newly created issue.

After issue creation

Automatically navigate to the newly created issue: Select this option to automatically navigate the user to the new issue created at the end of the transition. This is applicable only

when the

when the transition

was

is triggered from the View Issue page. 

(warning)Note that this

This requires the "Enable View Issue Screen Actions" option on the JMWE Configuration page to be enabled.

Note

After the issue creation, the  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 issueProperty Nunjucks filter. This can be used in other post-functions to refer to the last issue created by the Create issue post-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 jmwe-created-from of the newly created issue.   You can retrieve it later using the 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 can also, use it in the JQL searches using the syntax: issue.property[jmwe-created-from].key = TEST-123

However, there are caveats you need to be aware of:

  • the post-function that reads this property needs to run after 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 that creates a new issue, only the last issue created will be available in the jmwe.last.issue.created property. So this makes the feature unreliable if you're using the Create Issue post-function on multiple transitions of the same workflow.

Run As
  • .

Run As

Select one of the following to set the creator of the issue:

  • Run as current user: The current user will be the user that creates the new issue.

  • Run as add-on user: The add-on user will be the user that creates the new issue.

  • Run as this user: Any user selected in this field will be the user that creates the new issue.

Conditional execution

To execute this post-function based on the result of a Nunjucks template see Conditional execution
  • user

  • Run as this user:Select this option to enable the associated drop-down. Select a user from the drop-down to set the specified user as the creator new issue.

Conditional execution

  • 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 execution.

  • Condition (displayed only when the previous option is selected): Enter the Nunjucks template as needed.

Delayed execution

Include Page
Delayed execution
Delayed execution
Info

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. 

Use case

A typical use case for this workflow is to create one or more issues during a transition. Consider a use case where you want to create a documentation ticket only if "Needed" is selected in the "Documentation ticket" checkboxes field. To configure this:

  1. Add the Create issue post-function to the transition on whose trigger you want to create a documentation ticket

  2. Select Documentation from the Project field.

  3. Select Document from the Issue type field.

  4. Select caused by in the Link to new issue section.

  5. Add an appropriate Summary (such as Release documentation)

  6. Select the conditional execution and write the following template

Code Block
{{ issue.fields["Documentation ticket"] | find({"value":"Needed"}) != null }}

See here for more use cases.