Skip or follow a transition step based on cutom field value

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
Accepted answer

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.


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

@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.

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

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.

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

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?

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.

@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?

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.

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.  

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

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

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?

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

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

Janene 

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!

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. 

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.

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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,092 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you