Hi,
I want to create automatically creating subtasks for taken the custom field value(int) using script runner.
What do i need to do?
Anyone suggest to me.
There are a few scripts in the library you might want to have a look at (as in "copy them") - see https://library.adaptavist.com/search?page=1&products=jira&term=create
Hi @shital chande ,
You should be familiar to scripting. There are lots of examples in Vendor website and community, please check this link. After finalizing your code, go to
Following code may guide you create sub-task. You can convert according your needs.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.IssueInputParameters
try {
Issue issue = ComponentAccessor.getIssueManager().getIssueObject(issue.key);
IssueService issueService = ComponentAccessor.getIssueService();
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setProjectId(10000L);
issueInputParameters.setIssueTypeId("10000");
issueInputParameters.setSummary(issue.getSummary());
issueInputParameters.setDescription(issue.getDescription());
IssueService.CreateValidationResult createValidationResult = issueService.validateSubTaskCreate(loggedInUser, issue.getId(), issueInputParameters);
log.error(createValidationResult.errorCollection)
if (createValidationResult.isValid()) {
IssueService.IssueResult createResult = issueService.create(loggedInUser, createValidationResult);
if (createResult.isValid()) {
log.debug("Subtask successfully created : " +createResult.getIssue().getKey());
subtaskManager.createSubTaskIssueLink(issue, createResult.getIssue(), adminUser)
} else {
log.error("createResult is not valid.");
}
} else {
log.error("createValidationResult is not valid.");
}
} catch (Exception e) {
log.debug(e);
}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.