Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,463,428
Community Members
 
Community Events
176
Community Groups

How to show a new field based on another custom field value?

I have a use case.

There is a custom field as Change Result (with values "successful with errors" and "Failed" )

If the value in this field is "Failed"

Then I want to show a new field below this field as "Reason for failure" as a text field.

1 answer

1 accepted

2 votes
Answer accepted
Pramodh M Community Leader Feb 09, 2022

@Ankit Jaiswal 

Scriptrunner behaviours!!

Here's a guide

https://scriptrunner.adaptavist.com/5.6.8/jira/behaviours-overview.html

Thanks,

Pramodh

@Pramodh M 

I am new to scriptrunner. Can you send me the script for this use case.

I just want to put a condition on this new field "Reason for Failure" 

The condition will be if the "Change Result" value is "Successful with errors" then this new field will be hidden.

@Ankit Jaiswal 

Here's an example

def change_result = getFieldById(getFieldChanged()).getValue().toString()
if ( change_result == "Failed") {
getFieldById("customfield_10301").setHidden(false);
getFieldById("customfield_10301").setRequired(true);
}
else {
getFieldById("customfield_10301").setHidden(true);
getFieldById("custom field_10301").setRequired(false);
}

"customfield_10301" id is the id of the "Reason for failure" text field

Replace only the ID

You can get that when you edit the custom field, it will be visible in the URL

Let me know if you have any queries

Thanks,
Pramodh

Pramodh M Community Leader Feb 10, 2022

Hi @Ankit Jaiswal 

Let me know if you have tried this script and whether it's working?

Like Gerasimos Kardaras likes this

@Pramodh M 

In the behaviours you need to add the field that you would like to hide/show or the field that the code is based on?

Suggest an answer

Log in or Sign up to answer