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??
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.