State Auto-transition based on Custom Field Value

venkat patchigolla November 26, 2012

Hi All,

We have a requirement say, depending on the value of a Custom Field the story should Auto-Transition from one state to other state.

Example:- Assume the story is in Dev Integration Test state, at this point a custom field drop down (QA Integration Test) with Yes / No values is set. If the custom field value is set to Yes the story should auto-transition to QA Integration Test, if No to Move To QA Test state.

Solutions are most welcomed and much appreciated.

Thanks in Advance,
venkat

3 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 26, 2012

You'll need to write a listener plugin to do this (or use the Script Runner, which allows you to code without having to write a whole new plugin)

I've said to use a listener because that can detect and run on any event you chose to trap. It sounds like you probably want to trap "edit" and then check the status and custom field valures. It's also a nightmare trying to trigger a second transition in a post-function - don't even think about trying that! I've yet to see one work at all.

venkat patchigolla November 26, 2012

Thank You Nic for the valuable information

Supriya Jha April 4, 2019

@Nic Brough -Adaptavist- : Is this still the existing solution or do we have something better now?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2019

It remains the best answer.  I don't believe there is a better way to do it until the whole workflow and events system is redesigned.

Like Supriya Jha likes this
Supriya Jha April 10, 2019

Hi @Nic Brough -Adaptavist- : I am trying to write a listener in ScriptRunner but the REST API documentation is overwhelming. Is there an existing script for triggering transition when issue is updated? I selected event as "Issue Updated" and I want to evaluate the value of a custom field called "Life Safety Systems", if it is 'Yes' I want status to take on value 'A' and if it is 'No' I want status to take on value 'B'.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 17, 2019

I think https://library.adaptavist.com/entity/transition-an-issue-using-issue-input-parameters is a good basis for what you need.

You actually need two parts though - your workflow is going to need two transitions, one to A and one to B, then the listener can decide which one of the two to use

0 votes
Sonesh Jane July 31, 2015

Hi Florin, I don't have the exact same situation, but similar lines

Whenever an issue is created it has a "Draft" status. the next status it transitions into is "Waiting for approval" and then "approved"

I want the issue to automatically transition from "Draft" to "Approved" if a certain field has a specified value. In this case, the field is Type and value is "Standard".

So if the issue is of the type "Standard" then it should go from "Draft" to "Approved" else it should follow its natural route.

0 votes
Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 26, 2012

You can also use JJupin for that. Auto-transitioning an issue through the workflow is as easy as writing

autotransition(<transition_name_or_id>, <issueKey>);

You can either run this in a Listener (created with JJupin as well) or directly as a post-function (I see Nic hasn't tried JJupin yet).

HTH

Beppe Marcon July 2, 2019

Currently I implemented a Listener which transitions the ticket when it receives an Update event but realized there's a criticality in Jira's implementation whereby the issue might be in an inconsistent state just after having been updated and the transition fails, the result is that Jira returns an:

"It seems that you have tried to perform a workflow operation (some-transition) that is not valid for the current state of this issue"

Of course the transition is valid instead.

Someone suggested setting the workflow states which are null or 0 to "ACTIVATED" manually through the following code:

List<GenericValue> workflowEntries = ComponentAccessor.getOfBizDelegator().findByAnd("OSWorkflowEntry", FieldMap.build("id", issue.getWorkflowId()))for (GenericValue workflowEntry : workflowEntries){if (workflowEntry.getInteger("state") == null || "0".equals(workflowEntry.getInteger("state").toString())){workflowEntry.set("state", new Integer(WorkflowEntry.ACTIVATED))workflowEntry.store()}}

However this solution doesn't seem to work for me.

Suggest an answer

Log in or Sign up to answer