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.
I hope that my understanding is correct:
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After some modification I can make it run:
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == '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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.