Versions Compared

Key

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

This section has use cases that help you in understanding the usage of post functions. A few post-functions of JMWE have been deprecated and will no longer be enhanced. However, they still continue to work and you can configure and use the post-functions. But it is recommended to use their replacements instead.

...

Table of Contents
maxLevel4

Assign to role member

A workflow post-function that assigns the target issue to a member of a selected project role. 

Sample use cases:

(lightbulb) On the creation of a Bug assign it to a user only if he is a Product Owner

...

Assign to last role member

A workflow post-function that assigns the target issue to the last assignee who belongs to the selected project role.

Sample use cases: 

(lightbulb) When a tester reopens an issue assign the issue to a Developer who last worked on it.

...

Expand
titleSteps
  1. Add the “Build-your-own (scripted)” post-function to the transition

  2. Input the following Nunjucks template

    Code Block
    {{ "/rest/api/2/issue/:issue/worklog" | callJira(verb=("post"), params={"issue":issue.key}, 
    body={ 
      "timeSpent": "1w" 
    }
    ) | dump(2) }}

  3. Save the post-function and publish the workflow

Clear fields

A workflow post-function that clears the value(s) of the selected field(s) of the target issue.

(lightbulb) Clear the Fix Version/s field on the reopening of a ticket.

...

Expand
titleSteps
  • Add the Clear field value of linked issues post-function to the Abort transition of the workflow.

  • Select all the fields to be emptied from Field

Comment issue(s)

A workflow post-function that creates a comment on the target issue(s). The text of the comment to be created can be any simple text or a text with Nunjucks annotations.

Sample use cases:

(lightbulb) A customer using Jira Service Desk should be notified via comment when someone has started working on their support request.

...

Copy comments to related issues

A workflow post-function that copies the comment(s) of the current issue to the specified related issues

Sample use cases:

(lightbulb) When a developer transitions an issue to "Customer Feedback" copy the developer's comment on the transition screen to the linked issue.

...

Expand
titleSteps
  • Create a global transition “Sync Comments”

    • Add the Copy comments to related issues post-function to the transition

    • Select the “Target issue(s)” as “Issues linked to the current issue through the following link type:”

    • Select “causes” under “Issue Link”

    • Choose All comments

    • Add another Copy comments to related issues post-function to the transition

    • Select the “Target issue(s)” as “Issues linked to the current issue through the following link type:”

    • Select “is caused by” under “Issue Link”

    • Choose All comments

    • Add a few seconds delay

  • Click on Add

Now when you trigger the transition on the issue(s), the newly added comments on the issue are added to the linked issue

Create issue

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.

Sample use cases:

(lightbulb) Create a documentation ticket only if "Needed" is selected in the "Documentation ticket" checkboxes field

Expand
titleSteps
  • Add the Create issue post-function to the transition on whose trigger you want to create a documentation ticket

  • Select Documentation from the Project field.

  • Select Document from the Issue type field.

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

  • Add an appropriate Summary (such as Release documentation)

  • Select the conditional execution and write the following template

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

...

Copy field value from linked issues

A workflow post-function that sets the value(s) of a selected field to the value(s) from the same/different field of an issue linked to the current issue through a selected link type.

Sample use cases:

(lightbulb) Copy the Fix Version/s fieldfrom the Epic to a Story, while creating a Story.

Expand
titleSteps
  • Add the Copy field value from linked issues post-function to the Create transition of the Story workflow.

  • Choose the has Epic link type.

  • Select Fix Version/s in Source Field.

  • Select Same as source field in the Destination field.

...

Copy field value to linked issues

A workflow post-function that copies the value(s) of a selected field into the same/different field of all issues linked to the current issue through a selected link type.

Sample use cases:

(lightbulb) Copy the Fix Version/s field from the Stories to Epic, after resolving a user story.

Expand
titleSteps
  • Add the Copy field value to linked issues post-function to the Resolve transition of the Story workflow.

  • Choose the has Epic link type.

  • Select Fix Version/s in Source Field.

  • Select Same as source field in the Destination field.

  • Check Add value(s) to the linked issue option.

...

Copy field value from parent issue

A workflow post-function that sets the value(s) of a selected field with value(s) from the same/different field of an issue's parent issue.

Sample use cases:

(lightbulb) When creating a child bug of another bug (i.e. the parent bug), copy the fields Assignee, Component and Affect versions if they are left empty. 

Expand
titleSteps
  • Add the Copy field value from parent issue post-function to the Create transition of the sub-task workflow.

  • Select Assignee in Source Field.

  • Select Same as source field in the Destination field.

  • Select Copy only if not set option.

  • Repeat the above steps for the Component/s and Affects Versions fields.

Copy field value to parent issue

A workflow post-function that copies the value(s) of a selected field to the same/different field of the issue's parent issue.

Sample use cases :

(lightbulb) Copy the labels from each sub-task to its parent when the sub-task is closed.

Expand
titleSteps
  • Add the Copy field value to linked issues post-function to the Create transition of the Sub-task workflow.

  • Select Labels in Source Field.

  • Select Same as source field in the Destination field.

  • Check the Add subtask's value(s) to parent issue option.

Copy value from field to field

A workflow post-function that copies the value(s) of a selected field to another field of the same issue. 

Sample use cases :

(lightbulb) Set the component of an issue with a value selected from a cascading field that carries the Main and Sub-components in parent and child.

Expand
titleSteps
  • Add the Copy value from field to field post-function to the Create transition of the issue workflow.

  • Select the Cascading field as the From field.

  • Select the Components field as the To field.

  • Select Return "parent - child" for cascading custom fields option.

Note: The Component name should be in Component - Subcomponent format.

...

Expand
titleSteps
  • Add the Copy value from field to field post-function to the Close transition of the issue's workflow.

  • Select the Single version picker in the From field.

  • Select the Fix Version/s in the To field.

  • Select the Conditional execution check box Run this post-function only if a condition is verified.

  • Write the following content in Condition.

    Code Block
    {{ issue.fields.resolution.name == "Fixed" }}

Delete issue

A workflow post-function that deletes one or more issues.

Sample use cases:

(lightbulb) Automatically move the issue to a project when it is approved.

...

Expand
titleSteps

Not suggested

  • Add the Delete issue post-function to the Reject transition of the Story workflow.

  • Select the “Target issue(s)” as “Sub-tasks of the current issue”

  • Save the post-function and publish the workflow

Display Message to user

A workflow post-function that displays a message on the issue view page to the user triggering the transition. 

(lightbulb) On triggering a transition display a notification message on the issue view if a new issue has been created by the Create Issue(s) post-function with a link to the newly created issue.

Expand
titleSteps
  • Add the Display Message to User post-function to a transition.

  • Input the "Message title" as New issue created

  • Input the "Message body" as:

    Code Block
    A new ticket has been created.
  • Select the "Message type" as Warning

  • Select the "Action link" option

  • Input the "Action title" as Go to the created issue

  • Select the "Navigate to URL" option

  • Input the URL as

    Code Block
    https://myjira.atlassian.net/browse/{{ issue | issueProperty("jmwe.last.issue.created") }}

The message will be displayed as shown below in the issue view.

Email issue

A post-function that will send an email to certain recipients of the target issues specified in the post-function configuration.

Sample use cases:

(lightbulb) Send an Email to the voters of the issue when a new feature is approved.

Expand
titleSteps
  • Add the Email issue post-function to the Approve transition of the issue's workflow.

  • Input the subject of the Email in Subject

  • Select the Voters in Issue members under Recipients.

...

Expand
titleSteps
  • Add the Email issue post-function to the Create transition of the issue's workflow.

  • Select the “Target issue(s)” as “Issues linked to the current issue through the following link type”

  • Select “blocks” as the “Issue Link”

  • Input the subject of the Email in Subject

  • Select “Reporter” under “Issue members”

Increase value of field

A workflow post-function that increases the value of a selected numerical field by one.

Sample use cases:

(lightbulb) Track the number of times a bug fix was rejected by the QA team.

...

Link issues to the current issue

A post-function that will link the current issue to all issues that satisfy a parameterized JQL query.

Sample use cases:

(lightbulb) Link all the Faults in Service desk project to the current issue with "blocks" link type

...

Sequence of post-functions

A post-function that runs a sequence of JMWE post-functions on the target issues. This is the easiest way of making sure that a series of post-functions run in a predictable order during a transition - it is easier and more reliable than using Delayed execution as was previously recommended.

(lightbulb) Create a new issue (using the Create Issue(s) post-function) and then send a notification email mentioning the new issue.

Expand
titleSteps
  • Add the Sequence of post-functions post-function

    • Add the Create issue post-function to create a subtask

    • Add the Email issue post-function to send an email. Refer to the issue created by the previous post-function using this:

      Code Block
      {{ issue | issueProperty("jmwe.last.issue.created") }}
  • Save the post-function

...

Expand
titleSteps
  1. Add the "Sequence of post-functions" post-function to the transition

    1. In the sequence add the Assign to role member post-function

    2. Select the project role “Developers”

    3. Save the post-function

    4. Add “Email issue” post-function

    5. Input the “Subject” and “Body” of the Email

    6. Select “Assignee” under “Issue members”

    7. Save the post-function

  2. Click on "Save"

  3. Publish the workflow.

Set field value

A workflow post-function that sets the value of a selected field of the target issues to the specified value

Sample use cases:

(lightbulb) Assign a reopened issue to the last person who last commented it.

Expand
titleSteps
  • Add the Set field value post-function to the Reopen transition of the issue's workflow.

  • Select the Assignee field.

  • Write the following content in the Value section

    Code Block
    {{ issue.fields.comment.comments | last | field("author.accountId") }}

...

Expand
titleSteps
  • Add the Set field value post-function to the transition

  • Select the Checkboxes field.

  • Write the following in the Value section

    Code Block
    {% set regExp = r/^Installation.*/i %}
    {% set newValues = [] %}
    {% for option in issue.fields["Tasks list"] -%}
    {% if regExp.test(option.value) %}
    {% set ignore = newValues.push(option) %}
    {%endif%}
    {%- endfor %}
    {{newValues | join(',',"value")}}

(lightbulb) Add the time spent during the rework on an issue in the Rework Hours custom field, every time a rework is performed on the ticket

Expand
titleSteps
  • Add the Set field value post-function to the transition that leads to testing after Rework

  • Select the Rework Hours field.

  • Write the following in the Value section

    Code Block
    {% set worklog = issue | worklog %}
    {% set recententry = 0 %}
    {% for entry in worklog %}
      {% if now | date('diff', entry.updated) < 10000 %}
        {% set recententry = entry.timeSpentSeconds %}
      {% endif %}
    {% endfor %}
    {{ (recententry + issue.fields["Rework Hours"] * 60 * 60) / 3600 }}

...

Set field value from user entity property value

A workflow post-function that sets the value of a selected field of the current issue to the value of a User Property of the current user.

Sample use cases:

(lightbulb) Store the Country, Department, Location, and Pin information of the Reporter of an issue into the issue itself while creating it.

...

Shared Action post-function

A post-function that runs an Action (a sequence of one or more JMWE post-functions), created in the Shared Actions page, on the target issues.

Sample use cases:

(lightbulb) Setting multiple field values on the Create transition of every workflow of the instance

Expand
titleSteps
  1. Go to Manage apps → Jira Misc Workflow Extensions - >Shared Actions

  2. Click on "New Shared Action"

  3. Name it - "Set fields"

  4. Click on "Add post-function"

    • Add the Set field value post-function and configure it to set a field value

    • Click on "Save"

    • Repeat step 4 and add all other post-functions

  5. Click on "Save"

  6. Go to the "Create" transition of a workflow

  7. Add the "Shared Action" post-function

  8. Select "Set fields" shared action

  9. Click on "Save"

  10. Publish the workflow

  11. Repeat the same with the "Create" transitions of all other workflows.

Transition issue(s)

A workflow post-function that triggers a transition on the target issues. This can be used to an issue one step further in the workflow.

Sample use cases:

(lightbulb) Start the progress on an issue immediately after its creation. 

...

A workflow post-function that triggers a transition on all issues linked to the current issue through a selected link type.

Sample use cases:

(lightbulb) All the cloned issues of an issue should transition through the workflow in parallel with the current issue.

Expand
titleSteps
  • Add the Transition linked issues post-function to all the transitions of the workflow, except the Create transition.

  • Input the transition name or ID.

  • Choose the link type as clones.

  • Place this post-function at the end in the list of post-functions.

...

A workflow post-function that triggers a transition on the parent issue of the current issue.

Sample use cases:

(lightbulb) Start progress on the parent issue when someone started working on its sub-task.

Expand
titleSteps
  • Add the Transition parent issue post-function to the Start Progress transition of the workflow.

  • Input the respective transition name/ID.

  • Place this post-function at the end in the list of post-functions.

...