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?
Just use a separate post-function, which should come first:
issue.description = "some long description\netc etc"
Thank you for the answer Jamie . As I understood you mean addition another post function before "Create a sub-task". What kind of post-function should it be? Script post-function -> Define path to own written script? Or probably I avoid creation of new script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, that one. I don't see why you want to avoid another script. Scripts become classes... then they're exactly the same as the class shipped in any other plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't compile it, just copy the groovy file to the server under your script root and point the post-function to it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you're probably applying the same workflow to both standard issue types and subtasks. You will need a different workflow for the parent, or better: if (! issue.isSubTask() { ... set description }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This way works perfect: if (! issue.isSubTask()) { ... set description } Thank you again, Jamie
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.