Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change field color when another field changed

aas
Contributor
October 7, 2019

Hello everybody. I have 2 different custom fields in issue (e.g cF1 and cF2) and I need functionality when I change cF1 the cF2 should changed automatically to another value and should be hilighted with some color. 

I suppose I can use Custom Script Field, where in InlineScript field I can write script which returns the value of cF2 to custom template field, where I can change color of field. 

But:

1. what should I do to change cF2? (Write a custom listener script, which changes cF2 when cF1 changed or I can change cF2 in the Custom Script Field or some other ideas)?   

2. how to write template, which changed field background? (please example) 

1 answer

1 accepted

1 vote
Answer accepted
Gezim Shehu [Communardo]
Community Champion
October 7, 2019

If you create a Scripted Field, it does not hold any value.

It only renders what you have scripted, on the fly.

 

So if cf2 is outputting a value, based on cf1 value, then if cf1 changes, also the cf2 output will change.

Gezim Shehu [Communardo]
Community Champion
October 8, 2019

No that tutorial involves javascript, meaning using Jira stock.

 

You just need to create a scripted field, select it's output format (template) "HTML".

Then you can use groovy to calculate the logic and return a html in string format.

 

Example

def returnArg
switch(issue.priority.name){
case "Low":
returnArg = "green"
break
case "High":
returnArg = "red"
break
default :
returnArg="yellow"
break
}
return "<h4 style='color:${returnArg}'>Test me</h4>"

Suggest an answer

Log in or Sign up to answer