Hi,
We have a scripted field called "Aging" where we calculate the number of days between Today's date and Star date.
Here we need to change the background color of the Aging field based on the below logic.
Aging >= 7 days and <15 days - GREEN
Aging >= 15 days and < 20 days - YELLOW
Aging >= 20 days - RED
I am new to scripting. Please provide the script if you have any. Thanks in advance!!!
Hi,
You can achieve this with a web panel Fragment in scriptrunner.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issue = context.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_12603")// put your customfield ID
def cFieldValue = issue.getCustomFieldValue(cField) as Integer
def color = ""
if (cFieldValue == 0){
color = "grey"
}
if (cFieldValue > 0 && cFieldValue <100){
color = "#FFAE42"
}
if (cFieldValue >= 100){
color = "#63D13E"
}
// change the customfield id val to your customfield id val.
writer.write("<script>var css = '#customfield_12603-val { color: white;background-color: ${color}; font-weight: bold; border-bottom: 2px solid ${color}; }', head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style');head.appendChild(style);style.appendChild(document.createTextNode(css));</script>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.