Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,218
Community Members
 
Community Events
184
Community Groups

workflow post function issue

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

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023 • edited

Hi @Sasha Pilote

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events