There are 3 fields (Start Date, End Date and Summery ) which I want to copy from parent issue to sub-task.
While creating sub-task, value of these fields need to populate on create sub-task screen.
How should I write Behavior for this requirement.
Hi @RSP ,
If you are looking to copy the field value when a sub-task is created, you can add them as a post-function on create issue transition.
JWME app offers a post-function "Copy field value from parent issue (JMWE app)".
Here is a script runner code - https://library.adaptavist.com/entity/copy-field-value-from-parent-issue-to-sub-task-upon-creation
Add this as the first post function on the Create step of a workflow
Thank You
@RSP - Kindly accept the answer so that the post will be marked as SOLVED. Thanks and Good luck
Hi @Niranjan , I found code to copy custom fields from parent issue to sub-task.
I have written behavior for same.
@RSP
Hi RSP,
I am also looking for the same.
can you please share the behavior code which worked good for you.
I use the JMWE (Copy field value from parent issue (JMWE app)) ,it can copy fields from parent fields after created the subtask, not before.
I also use Create Subtask - JCTS ,but this plug can not copy the system fields values.
Neither of these are ideal.Is there a better way to automatically integrate the field values of the parent task when we create a subtask?
Hi everyone
I sure hope you can assist. And I am positive I am probably doing something simply wrong. But I cannot get this to copy fields from the parent to the sub-task on creating. Can someone look at my script
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 || underlyingIssue) {
// this is not a subtask, or the issue has already been created and we don't need default values
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(SUMMARY).setFormValue(parentIssue.summary)
getFieldById(PRIORITY).setFormValue(parentIssue.getPriority().id)
//getFieldById(SUB PROJECT).setFormValue(parentIssue.Sub Project*.id)
//getFieldById(TARGET TYPE).setFormValue(parentIssue.Target Type*.id)
//getFieldById(COMPONENT/S).setFormValue(parentIssue.Component/s*.id)
//getFieldById(TEST ISSUE TYPE).setFormValue(parentIssue.Test Issue Type*.id)
//getFieldById(SOC NAME).setFormValue(parentIssue.SoC Name*.id)
//getFieldById(SOC REVISION).setFormValue(parentIssue.SoC Revision*.id)
//getFieldById(SOFTWARE APPLICATION).setFormValue(parentIssue.Software Application*.id)
//getFieldById(DESCRIPTION).setFormValue(parentIssue.description)
//getFieldById(LABELS).setFormValue(parentIssue.labels)
Hi Patricia. Do you have Automation for Jira installed in your system? This can be accomplished using that plugin much more easily
Unfortunately, I do not. However, I didn't think it could do it on actual create only when you click create?
It looks like you're new here. Sign in or register to get started.