Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,693
Community Members
 
Community Events
165
Community Groups

Hide one transition and show another transition based on custom field value entered

Hello Community, 

 

Please advise or help me. Its server instance of jira. I have scriptrunner  and JMWE plugins.  I am working on a workflow of a story. Workflow has Start, Status B, Status C, Status D, Status E and Completed. 

Problem : 

My story has a customfield : Test Analyst ( Single Line Text Field) and its in Status B in workflow transition.   If  Test Analyst field has been populated with analyst's name  then story's view screen should shows Status E transition button, mean to story will transition to Status E from Status B. 

If Test Analyst field has not been populated with analyst name then story view should show Status C transition button.   mean to story will transition to Status C from Status B.

 

Please advise me how to accomplish this task. 

Thank you so much. 

Regards,

Anupam

 

  

3 answers

2 accepted

0 votes
Answer accepted

Hi @Anupam Sinha 

Are you on server or cloud. You can use Script Conditions to check for a specific field value. It can also be done with JMWE. I explained how to achieve this here, the example I used was to build an approval system and show transitions only when a condition is met.

You can do something similar on cloud as well but the main idea is to use Conditions.

I hope it helps.

Ravi

Thank You @Ravi Sagar _Sparxsys_ for helping me. It is nice and detail video. 

0 votes
Answer accepted

Hi @Anupam Sinha 

with JMWE, you can use a Build-your-own Condition on both transitions (B to E and B to C). For transition to E, use this script:

issue.customfield_12345 != null

and for transition to C, use this script:

issue.customfield_12345 == null

Note that customfield_12345 needs to be replaced with the field ID of your "Test Analyst" custom field, which you can find on the "Issue Fields" help tab of the editor.

Thank You David for quick help. It is helpful. 

Hi @David Fischer _Appfire_ ,

I am checking the value of Label and hiding/ displaying the transition. It works fine if Label field is not empty. But When Label is Empty It does not work.

for (label in issue.get("labels"))
if (label.getLabel()!="CX" )
{
return true
}
return false

 Transition 'x' will be hidden even if Label is empty. How to check for empty value in label

 

Thanks 

Madhura

Hi @Madhura A 

try this:

!issue.get("labels")?.any{it.label == "CX"}
Like Madhura A likes this

Thanks! It worked

Hi @Anupam Sinha  You can do it easily with the help of Simple Scripted Condition which is a part of Script Runner and put this condition :- cfValues['Some Custom Field'] == 'Some Value'

As you have mentioned it's a single line text field, value is not constant in this case. Condition might fail sometime if Agent name is not correct or some spelling mistake while typing agent name in a field.

It's better to use User Picker if this field is for Analyst name or use Select List instead of Single line text field for Analyst name.


Thanks

Thanks @Vikrant Yadav  for help and a very good suggestion on the field type. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you