Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Rashmi Belur February 1, 2018

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
AUG Leaders

Atlassian Community Events