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.
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.IssueInputParameterstry { 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
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
It looks like you're new here. Sign in or register to get started.