I'm new to Jira Administration and scripting so I'm not sure if this is even possible.
I have two Select List (single choice) fields, one with values 1...10, another with values 1...5. What I'm trying to do is copy the 1...10 field over to the 1...5 but divide by to, thus converting 8-10 to a value of 5, 6-7 to a value of 4, etc.
We have the ScriptRunner plugin which has the built-in "Copy custom field values" script, however that looks to be a 1 to 1 conversion for custom fields so I don't think it will apply any math to the conversion.
Hi @Dan Earle ,
You are right; that script is only a copy from one to an other script which has proven immensely helpful when I have had to rationalize custom fields from too many to not quite too many.
The fact that you have ScriptRunner is a great start, however. There is no reason you couldn't write a Groovy script that does the same thing but with your arithmetic added into it.
Heading out a bit farther, I don't understand the use case you are citing here. Is this a one-time conversion from the 1 - 10 field to the recalculated or is this an ongoing thing? If this is an ongoing thing, a calculated field derived from the 1 - 10 field might be the way to go.
Yeah sorry this is a one time conversion. We're refining our processes a little and it requires the 1...10 to be converted to 1...5. If we can do this in the existing field then that would be great, but I figured we'd create a new field to keep the existing values just in case something went wrong.
This is from an existing script we have for another field, could it be modified to run as a standalone script to update the fields?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;
def CA = ComponentAccessor.getCustomFieldManager()
def Field = issue.getCustomFieldValue(CA.getCustomFieldObject('DropDownField'))
def Int = ((LazyLoadedOption)Field).getValue().toInteger()
return Int/2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that is a very good start to it. The Adaptavist documentation pages have TONS of good examples of how to run against filters and the like so, with that start and their examples, I am confident you will get there.
For me it is always a case of the start I've got (which never works the first time), the documentation pages and lots of grepping Google to piece together my approach and eventually I get there.
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.