Skip or follow a transition step based on cutom field value

Rizwan Rizvi February 27, 2013

I have a situation here

Normal Flow --------------------- Dev-Requestor-Close

Another flow is ------------------ Dev-Requestor-QA-Close.

Want some way to implement this based on if a checkbox is checked for QA and accordingly follow the route.

Any help appreciated.

5 answers

1 accepted

0 votes
Answer accepted
Rizwan Rizvi March 1, 2013

I was able to get around this.

Using Script Runner plugin from JIRA Marketplace.

First, created a field called QA testing Required with 2 values 'Yes' and 'No'.

I create 2 transitions by the same name so as not to confuse the user.

1. Script workflow function : Simple scripted condition : Checks script:

cfValues['QA Testing Required']*.value.contains('Yes')

This is now flowing to the QA person.

2. Script workflow function : Simple scripted condition : Checks script:
cfValues['QA Testing Required']*.value.contains('No')

This skips the QA and follows to the last step.


Ram Chavan September 9, 2013

I am having the same situation. Can you please explain your solution in detail.

Rizwan Rizvi September 10, 2013

@Ram,

What I essential did in my solution was to create a dropdown field with 2 values 'yes' and 'no'

I made 2 transitions named 'Ready to Test'. One of them ended up with the QA person if the feild was set to YES and if no the issue flowed directly to the end user for testing.

To accomplish the above i.e. which route to take I installed 'Script Runner plugin'.

Then in the workflow. Go to each transition and perform below steps

  1. Click on transition and select 'View Validators'
  2. Click on 'Add' link on the screen
  3. Scroll down and select 'Script Validator'
  4. Click on 'Simple scripted validator' [Built -in Scripts]
  5. Scroll down below condtion textbox
  6. Click on 'Has custom field value equal to'
  7. it will display "cfValues['SomeCustomField'] == 'Some Value'"
  8. Replce the code with my condtions as above.i.e. 'cfValues['QA Testing Required']*.value.contains('Yes')'

I used value.contains as its a drop-down value.

Should be pretty simple once this goes fine.

Indranil Mondal February 18, 2016

This issue can be resolved in much easier way by using 'condition' 'value field'.

Like Abraham_Nkoumbé likes this
Rizwan Rizvi February 19, 2016

I agree.

At the time when this solution was implemented I didn't have that option of Condition+ Value Field. I use the value field now and depending on the field value appropriate  transition is displayed. In order to have the user unaware I name both transitions as exactly same so the user clicks on the same button for either flow.

Albert Malagarriga December 16, 2016

hi @Rizwan Rizvi, can you explain why you have two transitions with the same name?

Rizwan Rizvi December 16, 2016

Albert,

I wanted my user to be unaware of the difference in transition. So when my approver clicks on that 'Ready to Test', he is not aware which flow would be taken up. That decision is through the condition field. If YES, the next step is 'In QA' and If NO, it skips QA and goes directly to the UAT part. makes sense?

EXCE Infr Supp PH MUSIC Group May 17, 2018

i am done with my script but the next question is, how would it know what transition to go to?

i need my transition to check if the location is CN, it should go to CN Validation, else, it goes straight to Approve transition. i dont know where to put the if, else.

Akbar N November 5, 2018

@Rizwan Rizvi 

Thanks for the info. Could you tell after this condition how you managed the skip flow. 

 

If value is Yes you will be showing the flow letting the user to move from one step to other as DEV > Requestor > QA > CLOSE. But if the value selected is 'No' then how you make the QA step skipped without any actions?

Rizwan Rizvi November 5, 2018

Akbar,

 

Yes. Basically had an extra transition which skipped the QA step. So the normal YES transition took the QA step too and NO went to CLOSE directly. This was implemented quite a while back and the current setup using VALUE FIELD as indicated by Indrani is much easier.

Akbar N November 5, 2018

Rizwan, Thanks for quick response. I was trying to achieve the same but how can i skip the step based on the value? The final action i need to make after checking the values comes yes then move to Close step instead of QA step from requestor step in your scenario.  

Rizwan Rizvi November 5, 2018

Akbar,

When the Requestor checks YES or NO for QA, lets call that transition APPROVE. 

 

When I had initially put in the issue here and resolved there was no built in script but now Script Runner plugin actually has a post-function called FAST TRACK TRANSITION.

 

You can specify your condition in there e.g. cfValues['Need QA Validation']*.value.contains('No') and when that APPROVE button is clicked and if the value is NO, the above post function will trigger and skip to the last transition for Close.

https://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html#_fast_track_transition_issue

1 vote
C_ Faysal
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.
February 27, 2013
I am kinda confused here. As you are talkin about workflows you may mix sth up ? Please clearify if this isn't maybe a transition thing. If so just add 2 transitions and configure a condition to each of them. Sth like "only show if..." Maybe you will need to install additional plugins to get this https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions
Rizwan Rizvi February 27, 2013

I do get what you are saying but in my case there is a field called 'Set for QA Testing'. Now this feild can have a 'YES' or 'NO' value.

If its YES, I want the flow to be

DEV > Requestor > QA > CLOSE

But if the value of this field is NO, the flow would be

DEV > Requestor > CLOSE.

Does this explain clearly?

Alan Williams May 13, 2015

Are you sure this isn't a post-function that would fast track to a status based on a custom field?

Janene Hoffmann January 19, 2016

Curious if you've any problems using post function fast track transition or how you got this to work

Janene 

Johannes Rudolf May 24, 2016

Well, it all depends on your target. In our case we have 5 possible transitions depending on a certain value in a certain custom field (which is a result of a multiplication during the previous transition). We thought about embedding a Groovy or Pyton script. But one condition for every single transition out of those 5 transitions is the most elegant solution. If the conditions is untrue the transition will be hidden. And it's far less effort compared to a script that has to be written before. Thank you Candy, you made my day!

anwar bushnaq August 1, 2016

It doesn't work with me, i created two transition with the same name then open one of them and add a validater  and am still able to move the ticket on the workflow no matter which custom field value is selected. 

0 votes
Bernd Anderer October 18, 2018

What about an additional intermediate status? This status checks the value of the field and transitions the issue to the according target status.

0 votes
Regis MASSICARD June 20, 2018

Well it seems that now you can't create 2 transitions with the same name any more...

0 votes
Deleted user September 1, 2016

A bit of a hack I was able to get working, was to use the free Automation add-on; https://marketplace.atlassian.com/plugins/com.atlassian.plugin.automation.jira-automation-plugin/server/overview.

By setting up a rule which fires a cron every minute, runs JQL to find issues where my custom field = x, and takes Transition Action to the desired status. It is not instant, but it met our needs and so far works great.

Suggest an answer

Log in or Sign up to answer