Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can you help me convert this script for jira cloud instance (copy value from epic to story)

test user
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 26, 2020

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = issue as MutableIssue


["Theme", "Risk", "No Risk"].each { cfname ->
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == cfname}
def epicCf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}
if (!cf || !epicCf) {return}

def epic = issue.getCustomFieldValue(epicCf) as Issue
if (!epic) {return}

def cfValue = cf.getValue(epic)

issue.setCustomFieldValue(cf, cfValue)
}

 

 

 

I have written this script for server instance I want to use same script for cloud Instance. here Risk and No risk custom fields are of type checkbox  Can anyone help me??

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
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 4, 2020

Hi Vrushali,

If I understand correctly, you are looking to sync the values of these custom fields in the epic to their child issues.  I have to admit that my groovy script knowledge is not great, and I don't know if this can be done in Jira Cloud today.

However Jira Cloud's own automation can help here. All Atlassian Cloud sites now have this available across project types.  My thought is that you could create a new automation rule for this.  The trigger could be various actions, such as issue creation, issue edit, or perhaps something else such as a run on a schedule.  It's the actions that I know can do this in automation.

Creating a new action to Edit Field, choose the field "Risk", then choose the ... menu for Copy from.  From there you should have the option to copy value from Epic.  You could then create a new action on the same automation rule to also edit the value of "No Risk" in the same manner.

Screen Shot 2020-05-04 at 3.38.54 PM.png

This approach has the benefit that there is no coding involved, and this can work to copy values between issues in Jira Cloud.  The one caveat about this is the difference between a project specific rule, and a global rule.  While global rules can satisfy this condition across all projects, the number of executions is limited, more details in View your usage.  If these issues are all in the same project, then a project rule would be best.  But since Epics can have issues that come from multiple projects it might not suffice in all situations. 

Does this help?  Please let me know either way.

Andy

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events