Copy Fix Version field value to Release Category using Behaviors [ScriptRunner]

Vasanth Kumar Makam May 1, 2018

Hi,

 

I would like to copy the field value from "Fix Version" to "Release Category" custom field using Script Runner behaviors. 

My goal would be to have this custom field "Release Category" updated whenever an issue's fixVersion is set OR the existing fixVersion's value is updated.

Please suggest .

2 answers

0 votes
Joshua Yamdogo @ Adaptavist
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.
May 8, 2018

Hi Vasanth,

I have answered a similar question here, using a Script Field to pull in data from the Fix Version field: https://community.atlassian.com/t5/Jira-questions/Copy-Fix-Version-field-value-to-Release-Category-using-Behaviors/qaq-p/786991#M254086

I'm not sure you will want to use a behaviour. Behaviours function on the Create Issue, Update/Edit Issue, Assign Issue, and Workflow Transition screens. If someone manages to edit the Fix Version(s) field through a different method, the value wouldn't be copied to the new custom field. If you don't expect that to happen, then I suppose a behaviour would work. You could also write a Script Listener that sets the "Release Category" field automatically whenever an issue is updated/created with a new value in the Fix Version field.

Thanks,

Josh

Vasanth Kumar Makam May 9, 2018

Thanks Joshua.

Link you have shared redirect me to the same page, is there any other link you are referring to?

Also, any chance you could help me with the grovvy script for listener?

My scenario: Copy fixversion value to release category(which is multi select custom field) whenever its updated.

 

Thanks

Vas

Vasanth Kumar Makam May 9, 2018

I am using the below code in listener to update "Release Name" from "fixVersion" but getting error

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor

def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Release Name"}
def calcField = customFieldManager.getCustomFieldObjectByName("Fix Version/s")
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), issue.getCustomFieldValue(calcField)),changeHolder)

Like Renan Barboza likes this
Vasanth Kumar Makam June 20, 2018

Joshua Yamdogo @ Adaptavist Can you please share the link you answered ?

0 votes
Vasanth Kumar Makam May 1, 2018

Joshua Yamdogo @ Adaptavist Please let me know if you can help me on this.

Suggest an answer

Log in or Sign up to answer