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,
This is my scenario:
I have some custom fields that control the percentage of an author over a song, those fields are:
SXNY - Song #X, Name Y -> X could go from 1 to 8, and Y goes from 1 to 10.
I created this script on the Script Console that returns 'true' or 'false' if the sum of the percentage of each song is different that 100 %
def issue = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body as Map
def customFields = get("/rest/api/2/field") //Function to get all custom field Ids
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>
def song_author_id = ""
def song_author_value = ""
def song_perc_id = ""
def song_perc_value = ""
def next_song_id = ""
def next_song_value = ""
for (int song_number = 1; song_number<=8; song_number++){
//logger.info(song_number.toString())
def song_percentages = []
song_author_id = customFields.find { it.name == "S${song_number}N1" }?.id
song_author_value = issue.fields.get(song_author_id)
logger.info("Song number: ${song_number}")
next_song_id = customFields.find { it.name == "Add Song ${song_number + 1}" }?.id
next_song_value = issue.fields.get(song_author_id)
def author_num = 1
while (song_author_value != null){
song_perc_id = customFields.find { it.name == "PS${song_number}N${author_num}" }?.id
song_percentages.add(issue.fields.get(song_perc_id))
author_num ++
song_author_id = customFields.find { it.name == "S${song_number}N${author_num}" }?.id
song_author_value = issue.fields.get(song_author_id)
logger.info("S${song_number}N${author_num}")
//logger.info(song_author_value)
}
def total_percentages = 0
for (song_percentage in song_percentages){
total_percentages = total_percentages + song_percentage
}
if (total_percentages != 100) {
logger.info("Total percentage in Song ${song_number} is not 100%, please validate, current value: ${total_percentages}")
return false
}
else if(next_song_value == "No"){
return false
}
else{
logger.info("Song ${song_number} looks good, starting analysis on next song")
}
}
return true
I then realized that I cannot use this kind of script on Workflow validation and it's limited to using Jira Expressions, can someone help me 'translate' this to Jira Expressions? Looks very complex to use some of the examples that I've seen.
Thanks in advance.