Hi there,
I have a main issue (issue-1) in project A, and some related to it issues (issue-2,issue-3,...) in project B.
They are linked - from issue-1 I can see link(s) "realize in" to issue-2,issue-3,...
On some action with issue-1 (transition? sub-task creation?) I need to create sub-task for issue-2 (in project B), and this sub-task should also have a link to issue-1.
How it can be done with JIRA?
I have ScriptRunner 3.0.5, but could you please point me to example of code?
And another important thing - this newly created sub-task should have some input from user during creation (at least Summary and Description). How to achieve this during transition?
Hi Vik,
One way to do this is using script runner for JIRA plugin. If you are familiar with groovy language then you can write a very simple script or use one of the built in scripts (create a sub task) during a workflow transmission. You can also have a look at the documentation.
Yes, I have ScriptRunner 3.0.5, but could you please point me to example of code? And another important thing - this newly created sub-task should have some input from user during creation (at least Summary and Description). How to achieve this during transition?
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.
Vik, There is a script which will give yo a hint (the script is not tested) of how your custom script should be. @Chander Inguva FYI depending on which version of JIRA you use the above link may contain outdated code. import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue Issue currentIssue = event.issue def user = ComponentAccessor.getJiraAuthenticationContext().getUser() def issueFactory = ComponentAccessor.getIssueFactory() def subTaskManager = ComponentAccessor.getSubTaskManager() def constantManager = ComponentAccessor.getConstantsManager() def issueManager = ComponentAccessor.getIssueManager() def issueLinkManager = ComponentAccessor.getIssueLinkManager() // get all the outward links from that issue def linkedIssuesList = issueLinkManager.getOutwardLinks(currentIssue.id) def realiseInIssues = [] // add in a list all the issues that re linked with a realize in link type for (issueLink in linkedIssuesList) if (issueLink.getIssueLinkType().name == 'realize in') realiseInIssues.push(issueLink.destinationObject) // for every link to currentIssue issue, create sub-tasks for (Issue linkedIssue in realiseInIssues) { MutableIssue newSubTask = issueFactory.getIssue() newSubTask.setSummary("Add a summary") newSubTask.setParentObject(linkedIssue) newSubTask.setProjectObject(linkedIssue.getProjectObject()) newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{ it.getName() == "Sub-task" }.id) newSubTask.setDescription("Add a description") // in order to create a link between two issues use the // issueLinkManager.createIssueLink(Long sourceIssueId, Long destinationIssueId, Long issueLinkTypeId, // Long sequence, com.atlassian.crowd.embedded.api.User remoteUser) // https://docs.atlassian.com/jira/6.4.1/com/atlassian/jira/issue/link/IssueLinkManager.html Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object> issueManager.createIssueObject(user.directoryUser, newIssueParams) subTaskManager.createSubTaskIssueLink(linkedIssue, newSubTask, user.directoryUser) log.info "Issue with summary ${newSubTask.summary} created" } Kind regards Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vik Kay,
If you have script runner add-on installed on your instance, you can create a post function on transition.
This is one of the possible solution.
What is you JIRA Version ? As, last free version of script runner is available only for JIRA 6.4.12 and script runner version is 3.1.4
https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner/versions
Regards
Chander Inguva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I have ScriptRunner 3.0.5, but could you please point me to example of code? And another important thing - this newly created sub-task should have some input from user during creation (at least Summary and Description). How to achieve this during transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.