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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner - Post Function - Clone and Issue, and links

Hello,

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

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 {it.name == '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.

Thanks,
Moga

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 {it.name == '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)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,401 views 12 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you