Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,673
Community Members
 
Community Events
168
Community Groups

Is there a way to add component to Story when change in Epic component

Is there a way to add component to Story when change in Epic component? I am using Behavior plugin and scriptrunner  4.3.1

 

I am using below script to populate Component from Epic to Story

 

package com.onresolve.jira.groovy.test.behaviours.scripts

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.web.util.OutlookDate
import com.atlassian.jira.web.util.OutlookDateManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript

import java.sql.Timestamp

@BaseScript FieldBehaviours fieldBehaviours

FormField field = getFieldById(getFieldChanged())
FormField parent = getFieldByName("Epic Link")
Long parentIssueId = parent.getFormValue() as Long

if (!parentIssueId || field.getFormValue()) {
// this is not a subtask, or the field already has data
return
}

def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// REMOVE OR MODIFY THE SETTING OF THESE FIELDS AS NECESSARY

getFieldById(COMPONENTS).setFormValue(parentIssue.componentObjects*.id)

 

When I use the similar script mentioned for Sub-Task it works, from https://scriptrunner.adaptavist.com/4.3.1/jira/recipes/behaviours/subtask-default-fields.html

Is there a way to achieve this from Epic to Story component .

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events