iThis This section has use cases which help you in understand the usage of Post-functions provided by JMWE.
...
Clear field of related issues
This post-function clears the value of the selected field(s) of the issue's related issues (such as linked issues, Stories of an Epic, Epic of a Story, subtasks of an issue, issues returned by a Groovy script or a JQL search, etc.)
...
Comment related issues
This post-function creates a comment on all issue's related issues (such as linked issues, Stories of an Epic, Epic of a Story, subtasks of an issue, issues returned by a Groovy script or a JQL search, etc.). The text of the comment can be either a text, optionally including a Groovy template markup, or the result of the evaluation of a Groovy expression.
Sample use cases:
An issue is blocking another and you want to ensure the Assignee of the blocked issue is notified when the impediment has been resolved.
Expand title Steps Panel - Add the Comment related issues post-function to the transition that resolves the current issue.
- Select
Issues linked to the current issue through the following link type
under Which Issue(s) Choose the issue link type
blocks
- Select the Comment type as
Groovy template
Write the following content in the
Comment
section.Code Block language groovy linenumbers true The impediment $issue.key- $issue.summary has been resolved.
Add a comment on all the sub-tasks when the parent is cancelled
Expand title Steps Panel - Add the Comment related issues post-function to the Cancel transition
- Select the Comment type as
Groovy template
- Select
Sub-tasks of the current issue
underWhich issue(s)
Write the following content in the
Comment
section.Code Block language groovy linenumbers true The parent of the issue i.e $issue.key has been canceled.
On the Approval of an issue, copy the comment added if any to its sub-tasks.
Expand title Steps Panel - Add the Comment related issues post-function to the Approve transition
- Select the Comment type as
Groovy template
- Select
Sub-tasks of the current issue
underWhich issue(s)
Write the following content in the
Comment
section.Code Block language groovy linenumbers true if(transientVars.comment) return transientVars.comment else return ""
- Move this post-function after the "Add a comment to an issue if one is entered during a transition" post-function.
The Service Desk Agent responsible for a support request should be notified when the linked Bug is resolved.
Expand title Steps Panel - Add the Comment related issues post-function to the Resolved transition of the Bug workflow.
- Select the Comment type as
Groovy template
- Select
Issues linked to the current issue through the following link type
under Which Issue(s) - Choose the issue link type
blocks
Write the following content in the
Comment
section.Code Block $issue.key has been resolved. You should get back to the customer.
Check the
Restrict to internal (Jira Service Desk only)
option to make sure the customer doesn't see the comment.
...
This post-function is used to set a field to the value of a User Propertyuser property of the current user or the user in an issue field.
Sample use cases:
Store the Country, Department, Location, and Pin information of the Reporter of an issue into the issue itself while creating it.
Expand title Steps Panel - Create a user entity property to store the Country information.
- Add the Set field value of user property post-function to the transition
- Select the field to which the Country information is supposed to be copied.
Repeat the above steps for all the other fields.
...
Display the Man hours (a custom Numeric field) of an Epic as the sum of Man hours of all the user stories linked to the Epic.
Expand title Steps Panel - Add the post-function Set field value of related issues to the Create transition of the Story workflow.
- Select the Man hours field.
Choose
Epic of the current issue
underWhich Issue(s)
- Select the
Value type
asGroovy template
Write the following content in the Value section.
Code Block <%=textutils.noNull(issue.get("Man hours")) + textutils.noNull(linkedIssue?.get("Man hours"))%>
Set the issue's due date to the maximum due date set in its sub-tasks.
Expand title Steps Panel - Add the Set field value of related issues to the Create transition of the subtask's workflow.
- Select the
Due date
field. Choose
Parent issue of the current issue
underWhich issue(s)
Select the
Value type
asGroovy Expressio
nWrite the following content in the
Value
section.Code Block issue.get("duedate")
Write the following in Conditional execution section
Code Block linkedIssue?.get("duedate") <= issue.get("duedate")
On the Approval of an issue copy its components to issues linked to it with duplicates link type, only if the linked issue belongs to the same project as the current issue.
Expand title Steps Panel - Add the Set field value of related issues post-function to the Approval transition of the issue's workflow.
- Select the
Components
field. - Select
Issues linked to the current issue through the following link type
underWhich issues
Choose the issue link type as
duplicates
Select the
Value type
asGroovy Expressio
nWrite the following content in the
Value
section.Code Block issue.getAsString("components")
Write the following in Conditional execution section
Code Block issue.get("project").getKey() == relatedIssue?.get("project")?.getKey()
On the creation of a sub-task add its summary to the description of its parent
Expand title Steps Panel - Add the Set field value of related issuespost-function to the Create transition.
- Select the
Description
field. - Select
Parent issue of the current issue
underWhich issue(s)
- Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true org.codehaus.groovy.runtime.NullObject.metaClass.toString = {return ''} relatedIssue?.get("description").toString() + "\n" + issue.get("summary")
Place the post-function after the Creates issue originally built-in post-function.
...
Set a custom field with the total work log entered during the rework on an issue
Expand title Steps Panel - Add the Set field value post-function to the Rework transition of the issue's workflow.
- Select the Time spent on rework custom field.
- Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true return issue.getModifiedFields().get("worklog")?.newValue?.worklogResult()?.getWorklog()?.getTimeSpent()
Assign a reopened issue to the last person who last commented it.
Expand title Steps Panel - Add the Set field value post-function to the Reopen transition of the issue's workflow.
- Select the
Assignee
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true if(issue.get("comment")) { issue.get("comment").last().getAuthorApplicationUser() }
Automatically add the Reporter of an Epic to the watchers of its User Stories while creating a Story.
Expand title Steps Panel - Add the Set field value post-function to the Create transition.
- Select the
Watchers
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true issue.epic?.get("reporter")
Select
Add source value(s) to destination
field optionPlace the post-function after the Creates issue originally built-in post-function.
Capture the developer who resolved an issue in a custom single-user picker field
Expand title Steps Panel - Create a
Resolved By
single-user picker custom field. - Add the Set field value post-function to the "Resolve Issue" transition.
- Select the
Resolved By
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block currentUser.name
- Create a
Assign the issue to the Project lead if the issue is unassigned
Expand title Steps Panel - Add the Set field value post-function to the Create transition of the issue workflow.
- Select the
Assignee
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block issue.get("project").getProjectLead()
Write the following content in the Conditional execution section.
Code Block issue.get("assignee")
Place the post-function after the Creates issue originally built-in post-function.
On creating an issue, pick the component of the issue from a cascading field that carries the Main and Sub-components
Expand title Steps Panel Add the Set field value post-function to the Create transition of the issue's workflow.
Select the
Component/s
field.- Select
Groovy expression
in theValue type
. Write the following content in it.
Code Block language groovy linenumbers true import com.atlassian.jira.issue.fields.CustomField; CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cascade"); def value = issueObject.getCustomFieldValue(customField); return (value?.get(null)?.getValue() + "-" + value?.get("1"))
Place the post-function after the Creates issue originally built-in post-function.
Set the Component/s of the issue to components whose lead is the current user
Expand title Steps Panel - Add the Set field valuepost-function to the Create transition of the issue workflow.
- Select the
Components
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true def components = issue.getAvailableOptions("components") def newComponents = components.findAll{ it?.getLead() == currentUser.getKey() } return newComponents
On creating a Bug set its Affects Version/s to the most recently released version
Expand title Steps Panel - Add the Set field valuepost-function to the Create transition of the Bug's workflow.
- Select the
Affects Version/s
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true def versions = issue.getAvailableOptions("versions") def versionMap = [:] if (versions) { versions.each(){ if(it.getReleaseDate()) { versionMap.put(it?.getReleaseDate(),it.getName()) } } } if(versionMap.min{it.key}?.getValue()) { return versionMap.min{it.key}?.getValue() } else { return versions = [] }
Place the post-function after Creates issues originally built-in post-function.
On creating a Bug with Highest priority set its Fix Version/s to the upcoming release
Expand title Steps Panel - Add the Set field value post-function to the Create transition of the Bug's workflow.
- Select the
Affects Version/s
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true def versions = issue.getAvailableOptions("versions") def versionMap = [:] if (versions) { versions.each(){ if(it.getReleaseDate()) { versionMap.put(it?.getReleaseDate(),it.getName()) } } } if(versionMap.min{it.key}?.getValue()) { return versionMap.min{it.key}?.getValue() } else { return versions = [] }
Write the following in Conditional execution section
Code Block issue.get("priority").getName() == "Highest"
Place the post-function after Creates issues originally built-in post-function.
Set the Affects Version/s of the issue to Affects Version/s of all its linked issues
Expand title Steps Panel - Add the Set field value post-function to the transition
- Select the
Affects Version/s
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
sectionCode Block Set versions = [] issue.get("issuelinks").each(){ versions += it.getDestinationObject().get("versions") } return versions
Set the due date to today's date
Expand title Steps Panel - Add the Set field valuepost-function to the transition.
- Select the
Due date
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true new Date()
Identify all comments made between transitions A and B and add them to a custom text field
Expand title Steps Panel - Create Date-Time picker fields
Date of Transition A
andDate of Transition B
- Create a Mulit-line text field
Comments between transitions A and B
- Add the Set field value post-function to the transition A
- Select the
Date of Transition A
field. - Select
Groovy expression
in theValue type
. Write the following in the
Value
sectionCode Block new Date()
- Add the Set field valuepost-function to the transition B.
- Select the
Date of Transition B
field. - Select
Groovy expression
in theValue type
. Write the following in the
Value
sectionCode Block language groovy linenumbers true new Date()
- Add the Set field value post-function to the transition on whose trigger you want to identify the comments
- Select the
Comments between transitions A and B
field Write the following in the
Value
sectionCode Block Comments between Transition A and Transition B are: <% issue.get("comment").each() { if(it.created > issue.get("Date of Transition A") && it.created < issue.get("Date of Transition B") || it.updated > issue.get("Date of Transition A") && it.updated < issue.get("Date of Transition B")) { print "Comment added/updated by: "+ it.getAuthorFullName() + " at " + it.getUpdated() + "\n" + it.body + "\n" } } %>
- Create Date-Time picker fields
Set the due date to issue created plus five days
Expand title Steps Panel - Add the Set field valuepost-function to the transition.
- Select the
Due date
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true issue.get("created") + 5
Select the Installation tasks in the Checkboxes/Multi-select type field when all the Installations are done
Expand title Steps Panel - Add the Set field valuepost-function to the transition.
- Select the
Checkboxes
field. - Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true issue.getAvailableOptions("<Name of the field>").findAll{ it.getValue().contains("Installation") }
On the creation of an issue set a custom text field called Current time to the current time in the current user's timezone
Expand title Steps Panel - Add the Set field value post-function to the Create transition of the issue's workflow.
- Select the Current time field.
- Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true import com.atlassian.jira.timezone.TimeZoneManager // access timeZone of current user def userTimeZone = getComponent(TimeZoneManager).getLoggedInUserTimeZone() c1 = GregorianCalendar.getInstance(userTimeZone); return c1.format("HH:mm")
Add the members of the selected Organizations to the Watchers of the issue
Expand title Steps Panel - Add the Set field value post-function to the transition of the issue's workflow.
- Select the Watchers field.
- Select
Groovy expression
in theValue type
. Write the following content in the
Value
section.Code Block language groovy linenumbers true import com.atlassian.servicedesk.api.organization.OrganizationService import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest def orgs = issue.get("Organizations"); if (!orgs) return []; def organizationService = getComponent(OrganizationService) def pagedRequest = SimplePagedRequest.paged(0,1000) Set users = [] for (org in orgs) { def query = organizationService.newUsersInOrganizationQuery().customerOrganization(org).pagedRequest(pagedRequest).build() result = organizationService.getUsersInOrganization(currentUser, query) if (result.isRight()) users.addAll(result.getRight().getResults()) } return users;
Add the issue to the current active Sprint
Expand title Steps Panel - Add the Set field value post-function to the transition of the issue's workflow.
- Select the Sprint field.
- Select
Groovy expression
in theValue type
. Write the following content in the
Value
section and replace the<Board Id>
with the actual board id in the code.Code Block language groovy linenumbers true import com.atlassian.greenhopper.service.rapid.view.RapidViewService import com.atlassian.greenhopper.service.sprint.SprintService import com.atlassian.greenhopper.service.PageRequests import com.atlassian.greenhopper.service.sprint.SprintQuery import com.atlassian.greenhopper.service.sprint.Sprint import com.atlassian.greenhopper.service.sprint.Sprint.State def boardId = <Board Id> def board = getComponent(RapidViewService).getRapidView(currentUser, boardId).get() def SprintService = getComponent(SprintService) def sprintQuery = SprintQuery.builder().states(Collections.singleton(State.ACTIVE)).build() def sprintsOutcome = SprintService.getSprints(currentUser, board, PageRequests.all(), sprintQuery) if (sprintsOutcome.isInvalid()){ throw new UnsupportedOperationException(sprintsOutcome.toString()) } def sprints = sprintsOutcome.get().getValues() if (sprints.size() > 1){ throw new UnsupportedOperationException("More than one sprint is active") } return sprints[0].getId()
...
Set issue, user or project entity property value post-function
This post-function is used to set the issue, user or project entity property.
Sample use cases:
On the creation of a ticket, create a user entity property Profession for the current user.
Expand title Steps Panel - Add the Set issue, user or project entity property value post-function to the Create transition of the issue workflow.
- Select
Current user
fromEntity
field. - Input
Profession
inProperty name
field. - Select
Constant or Groovy Template
inValue type
field. - Input
"Doctor"
in theValue
field. Place the post-function after the Creates issue originally built-in post-function.
...
Transition related issues
This post-function triggers a transition on all issues related to the current issue
Sample use cases:
Resolve the associated support request(s) when a bug is resolved, and copy all comments from the bug to the support request(s)
Expand title Steps Panel - Add the Transition related issues post-function to the transition Resolve of the Bug workflow.
- Input the transition name or ID of the Resolve transition of the support workflow.
- Select
Issues linked to the current issue through any link type
fromWhich Issues
- Set the
Comment
field to copy the comments from the current issue. - Place this post-function at the end in the list of post-functions.
...