Can anyone help with this? i want the value of my single select custom field to change to red and bold when i select test risk tier 1 but nothing is happening.. perhaps i am not injecting the code at the right point in the page.. its a single select text custom field that sits where you would expect it to.. see screenshot. any help would be greatly appreciated!
Condition:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def risk = customFieldManager.getCustomFieldObject("customfield_13300")
issue.getCustomFieldValue(risk) == "TEST RISK TIER 1"
Script:
writer.write("<script>var css = '#customfield_13300-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>")
Hi Peter,
I did something similar but I used scriptrunner behaviours.
The trick to execute javascript is...
def risk = getFieldById("customfield_13300")
risk.setHelpText('<script>Y O U R S C R I P T here</script>').
The helptext is sent to the screen and your script will be executed as soon as the screen displays.
Cheers
Heiko Gerlach
Accxia
Thanks for your help on this, however I am struggling to get it going, here is my script. Apart from the missing conditions on the if statements, can you see anything obvious? Its saying check the setHelpText method exists?
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
def CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def field1 = customFieldManager.getCustomFieldObject("customfield_13300");
def field2 = customFieldManager.getCustomFieldObject("customfield_13301");
if (field1 == “One”) {
arrivalrisk.setHelpText("var css = '#customfield_13300-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));")
} else if (field1 == "Two”) {
} else if (field2 == “Three”) {
} else if (field3 == “Four”) {
}
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.