I want to be use a behaviour to copy multiple fields from the parent to the subtask so they appear before i create the subtask.
I have figured out how to do the summary using other posts on the community, but i cant get the custom fields to work.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import java.sql.Timestamp
import static com.atlassian.jira.issue.IssueFieldConstants.*
@BaseScript FieldBehaviours fieldBehaviours
FormField field = getFieldById(getFieldChanged())
FormField parent = getFieldById("parentIssueId")
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()
def cfspid = getFieldByName("SPID")
// REMOVE OR MODIFY THE SETTING OF THESE FIELDS AS NECESSARY
getFieldById(SUMMARY).setFormValue(parentIssue.summary)
//getFieldById(SPID).setFormValue(field.cfspid)