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

Scriptrunner - Post Function - Clone and Issue, and links


Im creating 5 automatic Issuelinks with a PostFunction Scriptunner (Clone and Issue, and links) with that everythink is okey, the problem is I want to perform a "Aditional issue action" where (here is de difficult part) Want to copy a value from the Main Issue, but this customfield(text field single line) have a formated input like (CODE=VALUE;CODE=VALUE;...), in the linked issues need to sum each VALUE and then assign 20% of the sum in each issuelink.

Not sure if you this is posible from there, maybe other kind of function can resolve this.

From now thanks and have a nice day.Where I want to put the code.png

1 answer

1 accepted

1 vote
Answer accepted
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 13, 2021 • edited

Hi @Nicolás Figueroa,

I hope that my understanding is correct:

  1. Parent issue will have a custom field with value as per the following; CODE=VALUE;CODE=VALUE;...
  2. For the issues that we are automating the creation, we would like to process the string and assign 20% of the sum to each linked issues.
  3. So basically what the code needs to do is to get the content of the field, sum all the VALUE and then assign 20% of the sum to each linked issue.
  4. The custom field is the same for the parent and child issues.

Correct me if I'm getting anything wrong here. If I got it all right, then this should be script:

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'custom field name'}
def cfValues = sourceIssue.getCustomFieldValue(cf)
def cfValue = cfValues.split(';')

float value

for ( String item : cfValue ) {
value = item.split('=')[1]
value += value

def finalValue = value * 0.2

issue.setCustomFieldValue(cf, finalValue)

FYI, I didn't test the script. I hope that this helps.


Hello @mogavenasan 

Thanks for your quick response and yes you are undestading well the case.

I try the script and change the value for String because its give error (cause float value = String item) and then convert it a float, but im not sure if im doing it well.

Also the script gives this error:

script split.png

Updated: now have no error, but the field its not updated:


def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'custom field name'}
def cfValues = sourceIssue.getCustomFieldValue(cf) as String
def cfValue = cfValues.split(';')

float values

for ( String item : cfValue ) {
def value = item.split('=')[1]
values = value as Float
values += (float) values

def finalValue = values * 0.2

issue.setCustomFieldValue(cf, finalValue)

After some modification I can make it run:

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Custom FieldName'}
def cfValue = sourceIssue.getCustomFieldValue(cf)
//Use string array to hold all values and convert them to String
String[] cfValues = cfValue.toString().split(';')

double values = 0.0

for ( String item : cfValues ) {
//Convert the VALUES to duble
Double value = Double.parseDouble(item.split("=")[1])
values += value

//Convert to string because the customfield is SimpleText
def finalValue = String.valueOf(values * 0.2)

issue.setCustomFieldValue(cf, finalValue)
Like mogavenasan likes this

Hi @Nicolás Figueroa 

You have mentioned "Im creating 5 automatic Issuelinks with a PostFunction Scriptunner (Clone and Issue, and links)", How have you been creating 5 issue links with the single post-function? or you have used 5 post-function.


Hello @Teja

I have created 5 different post-functions with Scriptrunner.

Maybe you can create only 1 post-function that create 5 issuelinks but I believe you need to write some code.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events