Greetings,
We are looking to base the color of a custom field based on the value or comparison of another field.
Examples: We have a 'risk' field, 1-5 - based on the number, we would like to change the color of the field
We have an estimated completion date field. If the estimation is greater than the actual close date, we would want this to be a 'green' or 'red' date to see if the project finished on time or not.
We have ScriptRunner - if there's some simple code for that, this would be the preferred method. We'd rather not pay for a plugin like 'Rainbow Field' // not sure the cost would be justified.
We are running server 8.1 - Thank you!
Hi there
It's a bit a hack, but you can do that by injecting CSS-Code through the Scriptrunner (Web-)Fragments feature.
Here is a sample which sets the Story-Point field to "underline & red" as soon as it exceeds the value 13.
Condition Script
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectsByName("Story Points")[0]
def cFieldValue = (issue.getCustomFieldValue(cField) ?: 0) as long
log.warn('custom field value is: ' +cFieldValue)
(issue.issueType.name =='Story' && cFieldValue>13)
Provider class/script
writer.write("<script>var css = '#customfield_10002-val { color: red; font-weight: bold; border-bottom: 2px solid red; }', head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style');head.appendChild(style);style.appendChild(document.createTextNode(css));</script>")
The result will look like this:
Hi Leonard,
How do you change a color of an issue custom field, based on its value, in the issue search table?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What if I do not have ScriptRunner nor know how to use it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Leonard Chew ,
I want to use your code, but one thing doesn't work. I change the threshold from 13 to a number with decimal seperator like <1.5 but the color change to 2. It seems it's being rounded up. How can I solve this problem? Any idea?
Thanks in advance...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I'd just be interested, if there was a solution for this problem, and if you are willing to share some hints, because we're facing the same Problem here.
Thanks,
Moritz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Moriz,
Thanks for reaching out to Community!
I checked the ticket and the suggestion is to use Scriptrunner, since there are no features in Jira that allows changing the color of fields based on values.
You can also check this thread in community that may help you achieve that:
Regards,
Angélica
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stearns,
I saw that you created a ticket with our support related to the same question, so to avoid any possible misunderstandings or miscommunication that may arise from discussing the same matter in two different platforms, let's focus on the ticket instead.
Once the ticket is resolved, feel free to share the resolution here to help other people.
Regards,
Angélica
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.