You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi All,
I have created a scripted post function in my workflow. This function is to color issues based on the value of a custom scripted field called Rating. There are no errors in the script or failures, but i am not seeing the post function do it's thing. here is the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
// Set the name of the Rating field
def ratingFieldName = "Rating"
// Set the colors for each range
def redColor = "#FF0000"
def orangeColor = "#FFA500"
def yellowColor = "#FFFF00"
def noColor = "null"
// Get the custom field for the Rating field
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def ratingField = customFieldManager.getCustomFieldObjectByName(ratingFieldName)
// Get the Rating value for the current issue
def ratingValue = issue.getCustomFieldValue(ratingField) as Integer
// Set the color based on the Rating value
if (ratingValue >= 13 && ratingValue <= 16) {
["style": "background-color: $redColor"]
} else if (ratingValue >= 9 && ratingValue <= 12) {
["style": "background-color: $orangeColor"]
} else if (ratingValue >= 4 && ratingValue <= 8) {
["style": "background-color: $yellowColor"]
} else {
["style": "background-color: $noColor"]
}
i have selected the workflow as the transition view.
Any additional steps im missing?
Thanks,
Sasha
After going through your code, I have a question; i.e. in your if/else condition, I noticed that you are passing the colour into a Map, i.e. ["style": "background-color: <The Color>"].
But where is this map being passed to?
It would seem that the map's value is being set, but it is not being passed to anything else, resulting in no change taking place once the Post-Function is triggered.
Is there additional section in your code that is missing or not added to your description?
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.