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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Complex validation ScriptRunner


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')
.body as Map

def customFields = get("/rest/api/2/field") //Function to get all custom field Ids
.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++){

def song_percentages = []
song_author_id = customFields.find { == "S${song_number}N1" }?.id
song_author_value = issue.fields.get(song_author_id)"Song number: ${song_number}")

next_song_id = customFields.find { == "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 { == "PS${song_number}N${author_num}" }?.id
author_num ++
song_author_id = customFields.find { == "S${song_number}N${author_num}" }?.id
song_author_value = issue.fields.get(song_author_id)"S${song_number}N${author_num}")
def total_percentages = 0
for (song_percentage in song_percentages){
total_percentages = total_percentages + song_percentage
if (total_percentages != 100) {"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{"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.

0 answers

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events