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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Copy fix version from parent to sub task while creating sub task using script runner

Please can some one help me to write script runner script to " Copy fix version from parent to sub task while creating sub task ".

 

2 answers

fix version is a system field, not a custom field. This works for me

// inherit system fields
UpdateIssueRequest updIssReq;
UpdateIssueRequest.UpdateIssueRequestBuilder issueRequestBuilder = new UpdateIssueRequest.UpdateIssueRequestBuilder();
issueRequestBuilder.eventDispatchOption(EventDispatchOption.ISSUE_UPDATED);
issueRequestBuilder.sendMail(false);
updIssReq = new UpdateIssueRequest(issueRequestBuilder);

MutableIssue _subTask = issue as MutableIssue

def fixVersionsField = parentIssue.getFixVersions();
// add system fields to inherit before calling issueManager.updateIssue()
_subTask.setFixVersions(fixVersionsField);
issueManager.updateIssue(curUser, _subTask, updIssReq);


 

below script copies story points from parents to sub task while creating sub task but still i'm not able copy fix version like story points.

could some one help me to modify this script to copy fix version as well

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points")

//def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("fixVersion")

def parentMyFieldValue = issue.parentObject.getCustomFieldValue(field)
def changeHolder = new DefaultIssueChangeHolder();
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), parentMyFieldValue),changeHolder);

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

609 views 15 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you