...
Tip |
---|
title | Why on Earth would I need something like this? |
---|
|
A typical use for this workflow condition is when you can reach a certain Status from several other Statuses (through the same Transition) and want to be able to return to the originating Status. Consider the following partial workflow : JIRA will allow you to create a single Transition from both Open and In Progress statuses to the Waiting for clarification status. But how do you create the transition (Provide info) back to Open and In Progress? And, more importantly, how do you make sure the issue is transitioned back to the originating status? Here's the trick: - create two Provide info transitions, one from Waiting for clarification to Open, and another from Waiting for clarification to In Progress (just add a space at the end of the name of one of the two transitions so that JIRA doesn't complain about duplicate transition names).
- on the first transition, add a Previous Status Condition to make the transition available only if the previous status was Open (don't forget to check the "Most recent status only" checkbox).
- on the second transition, add a Previous Status Condition to make the transition available only if the previous status was In Progress (don't forget to check the "Most recent status only" checkbox).
And voilà! Your users will see only one transition from the Waiting for clarification status, and it will transition the ticket back to the originating status. Note that you could also use an advanced feature of JIRA that allows you to define conditional "<result>" elements in the XML definition of a transition, but you need to edit the workflow XML and this is definitely not for the faint of heart. Below is an example XML snippet extracted from a workflow XML (only the transition XML is shown): Code Block |
---|
|
<action id="801" name="Provide Information" view="fieldscreen">
<meta name="jira.description">Provide the requested information</meta>
<meta name="jira.fieldscreen.id">10010</meta>
<validators>
<!-- Force the user to provide a comment -->
<validator name="" type="class">
<arg name="errorMessage">You must provide your answer in the Comment field.</arg>
<arg name="class.name">com.innovalog.jmwe.plugins.validators.CommentRequiredValidator</arg>
<arg name="hidGroupsList"></arg>
</validator>
</validators>
<results>
<!-- Conditional results (transitions) first -->
<!-- First possible destination step: 1 ("Backlog") -->
<result old-status="Not Done" status="Done" step="1">
<conditions>
<!-- Transition will only be available when coming from the "Backlog" status -->
<condition type="class">
<arg name="jira.previousstatus">Backlog</arg>
<arg name="class.name">com.innovalog.jmwe.plugins.conditions.PreviousStatusCondition</arg>
<arg name="jira.mostRecentStatusOnly">yes</arg>
</condition>
</conditions>
<post-functions>
<!-- restore former assignee field from custom field "Previous Assignee" -->
<function type="class">
<arg name="sourceField">customfield_10090</arg>
<arg name="destinationField">assignee</arg>
<arg name="class.name">com.googlecode.jsu.workflow.function.CopyValueFromOtherFieldPostFunction</arg>
</function>
<!-- standard Jira functions follow -->
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.misc.CreateCommentFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.GenerateChangeHistoryFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.IssueReindexFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.event.FireIssueEventFunction</arg>
<arg name="eventTypeId">10008</arg>
</function>
</post-functions>
</result>
<!-- Second possible destination step: 1 ("In Progress") -->
<result old-status="Not Done" status="Done" step="3">
<conditions>
<condition type="class">
<arg name="jira.previousstatus">In Progress</arg>
<arg name="class.name">com.innovalog.jmwe.plugins.conditions.PreviousStatusCondition</arg>
<arg name="jira.mostRecentStatusOnly">yes</arg>
</condition>
</conditions>
<post-functions>
<function type="class">
<arg name="sourceField">customfield_10090</arg>
<arg name="destinationField">assignee</arg>
<arg name="class.name">com.googlecode.jsu.workflow.function.CopyValueFromOtherFieldPostFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.misc.CreateCommentFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.GenerateChangeHistoryFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.IssueReindexFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.event.FireIssueEventFunction</arg>
<arg name="eventTypeId">10008</arg>
</function>
</post-functions>
</result>
<!-- Last possible destination step: 7 ("Resolved") -->
<unconditional-result old-status="Not Done" status="Done" step="7">
<!-- no condition - will be executed if no conditional result above matched -->
<post-functions>
<function type="class">
<arg name="sourceField">customfield_10090</arg>
<arg name="destinationField">assignee</arg>
<arg name="class.name">com.googlecode.jsu.workflow.function.CopyValueFromOtherFieldPostFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.misc.CreateCommentFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.GenerateChangeHistoryFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.issue.IssueReindexFunction</arg>
</function>
<function type="class">
<arg name="class.name">com.atlassian.jira.workflow.function.event.FireIssueEventFunction</arg>
<arg name="eventTypeId">10008</arg>
</function>
</post-functions>
</unconditional-result>
</results>
</action>
|
You can also restore the previous Assignee by saving it in a custom field during the Request clarification transition and then restoring it during the Provide info transition (see Copy Value From Other Field workflow function in JIRA Suite Utilities). Alternatively, you can use the Assign to last role member function described below to assign the issue to the last user in the Users role. |
...
A worfklow function that copies the value(s) of a field into the same field of the issue's parent issue.
Set Field Value From Parent Function (new in 2.4)
A worfklow function that sets a field value to the value(s) of the same field of the issue's parent issue.
Copy Value From Field to Field Function (new in 2.3)
...