My goal is creation of some sub tasks in case of issue with issue type = Implementation is created.
I use script runner and it's "Create sub task" post-function - it copies (clones) all necessary fields of parent issue to sub task.
The issue I can't resolve is automatic change of parent issue description. E.g. I'm creating a new ticket and write issue description "Day-to-day contact: John Walter". As soon as the ticket and sub task are created I want to have following parent's issue description:
Here is the list of some little tasks which doesn't require separate ticket Task 1 Task 2 Day-to-day contact: John Walter
I defined following additional sub task actions:
issue.summary = issue.summary + ' Perform initial tuning' issue.description = 'Please perform initial tuning of a new client.'
So the question is: is there any way to change parent issue description within "Create sub task" script post-function?
I'm not familiar with coding... But looks like following script works (I will use it before "Creates the issue originally." import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.resolution.Resolution import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.event.type.EventDispatchOption //retrieve a specific issue //IssueManager issueManager = ComponentManager.getInstance().getIssueManager() //MutableIssue myIssue = issueManager.getIssueObject("PTTTTTTTT-119") //retrieve current issue (works for workflow post-functions) MutableIssue myIssue = issue //amend the issue description myIssue.description = "[Some text] - " + myIssue.description //If the issue is already created and you change the issue object after that, you have to update the issue manually. Do it with following code //user = componentManager.jiraAuthenticationContext.getLoggedInUser() //issueManager.updateIssue(user, myIssue, EventDispatchOption.DO_NOT_DISPATCH, false) Thank you, Jamie!
I'm trying to put the script on the server but not sure what it should be: a script or a class? When I'm trying to compile either script or class in Intellij IDEA I get following errors: Error:(10, 1) Groovyc: unable to resolve class com.atlassian.jira.event.type.EventDispatchOption Error:(6, 1) Groovyc: unable to resolve class com.atlassian.jira.issue.Issue Error:(9, 1) Groovyc: unable to resolve class com.atlassian.jira.ComponentManager Error:(8, 1) Groovyc: unable to resolve class com.atlassian.jira.issue.IssueManager Error:(7, 1) Groovyc: unable to resolve class com.atlassian.jira.issue.MutableIssue Error:(12, 1) Groovyc: unable to resolve class AbstractIssueEventListener Error:(15, 24) Groovyc: unable to resolve class IssueEvent Could you please advice here?
You're right - I've just renamed text file with a script to .groovy and it works now. Unfortunately I met one more issue: sub task description changes as well although I'm specified this strongly in "Create sub task" post function.. *The order of post-functions execution:* 1) Script /opt/atlassian/jira/ChangeImplementationTicketDescription.groovy will be run. 2) Creates the issue originally. 3) Script workflow function : Create a sub-task. Subtask will be created with issue type: Sub-task 4) Fire a Issue Created event that can be processed by the listeners. *The script I'm using:* import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.ComponentManager //retrieve current issue (works for workflow post-functions) MutableIssue issue = issue //amend the issue description issue.description = issue.description + "\n \n" + "some additional information" *Additional issue actions in "Create sub task" post-function:* issue.summary = issue.summary + ' Perform initial tuning' issue.description = 'Please perform initial tuning of the client. \n' + 'Currency sign is *$CURRENCY CODE*' *As a result I have parent ticket with description:* Some specific information some additional information *And description of sub task is:* Please perform initial tuning of the client. Currency sign is *$CURRENCY CODE* some additional information I've tried to move script execution to different positions but nothing changed (although I didn't use issueManager.updateIssue). Could you advice what I'm doing wrong? Probably I should use different class, not MutableIssue? Thank you for your help.
Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG