Good morning!
I am new with groovy / scriptrunner and I am having difficulties in writing a script. The request is to use a post-function in the Create transition workflow to re-route tickets to a specific user when issue type = ‘Incident’ and Component is not set.
My idea is to use the inline postfunction option to achieve this. Can anyone help with the script to do this? Thanks.
Hi Daniel,
To do this using a post-function you wil need to add this code:
import com.atlassian.jira.user.util.UserManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.component.ComponentAccessor UserManager userManager = ComponentAccessor.getUserManager(); MutableIssue issue = issue if(issue.issueType.name == "Incident" && issue.getComponents().size() == 0 ){ issue.setAssignee(userManager.getUserByName("Test")) }
Replace the 'Test' user with whomever you would like to set the issue to. The post-function will need to appear first in the list for this to work.
You could also do this as a behaviour on the 'Assignee' field and change it depending on the form field value of componant and issue type.
Let me know if this is what you were looing for, or if I have misundertood and you need some other solution.
Regards,
Johnson Howard
Thanks for your prompt response Johnson. I am still to test this as our associates have a new type of request now.
As soon as I have this tested, I will update this thread. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any update on this Daniel?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good morning Johnson,
Sorry for the late reply. Just able to test it now in our non-prod instance.
I am attaching three screen shots with the error messages. Hope you can get them.
Any suggestions? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of JIRA and ScriptRunner are you using?
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.
Try with just:
issue.assignee = userManager.getUserByName()
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.
If you update your JIRA and Scriptrunner, the previous code will work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a similar case, I want to copy custom field value of one issue type to all other issues of the project.
We have Issue type "Project info" and we created one issue of "Project info" type per project to maintain all project related information.
So anything changes in the project we update the respective field on of project info issuetype of that project.
Now I want to copy one of the custom field value of project info issue type to all other issue of that project.
Can anybody help me with this?
Thanks in advance.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.