Hi,
some of our users would like to have a workflow where the user can select an assignee while creating an issue and if not, the issue should be assigned to the current user. For this I'm thinking about writing a workflow validator Groovy script to validate if for assignee "Automatic" was choosen and if this is the case the assignee should be set to the current user.
What I didn't get is, how to get the value of the assignee field of the create screen.
issue.assignee is set to the resulting assignee if automatic is choosen, so this is not an option.
Did some have an idea how to get the assignee field value from the create screen from a validation script? Or maybe, any other idea to achieve the described behaviour?
Thanks,
Henning
Community moderators have prevented the ability to post new answers.
You can inspect the HTTP request for the "assignee" parameter. A null value = unassigned and a value of -1 = Automatic (which is what you want).
I haven't used groovy runner so I can't say if it can do this, but it can definitely be done if you write your own post-function.
Hope that helps.
Ok, thanks. Are these informations part of the params for the AbstractJiraFunctionProvider.execute() method call? Or were do I get the HTTP request?
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This should do the trick:
webwork.action.ActionContext.getRequest().getParameter("assignee")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And were do I get the webwork object? Sorry for all this questions...
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ActionContext is a static class
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok this works. For everyone who's interested:
Condition:
// Test if assignee is automatic webwork.action.ActionContext.getRequest().getParameter("assignee") == '-1'
Script:
issue.assignee = currentUser
Thanks for the help
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Henning,
You can write a workflow post-function which basically does this:
1. If "Assignee" is set to a user other than the current user, dont change anything.
2. If "Assignee" is not set or null, assign it to current user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, thanks. Do you know a way to do this if the Default Assignee is set to Project Lead?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Putting it all together for completeness:
import com.atlassian.jira.issue.MutableIssue import webwork.action.ActionContext if (ActionContext.getRequest().getParameter("assignee") == '-1') issue.assignee = issue.reporter
This worked for me as a Script Validation using the Script Runner plugin on Jira 6.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've tried the suggestions on this thread, but none seem to work for me within Script Runner on JIRA 6.x. I would simply like to set a specific user not the default Lead if the user doesn't specify an Assignee (i.e. they leave it set to Automatic). It works if I specify the Value type: 'Raw Value' with the Value set to the desired username. However, when I enable the 'Conditional execution check-box', to only run the script if the Assignee is left as 'Automatic', but it doesn't work. I've enabled logging, but I never seem to get anything useful. 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.
This script has to be added as "Script Validator" under Validators. It is not a Post Function. Works for me in JIRA 6.1. Here's the modified code: {code} import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue import webwork.action.ActionContext if (ActionContext.getRequest().getParameter("assignee") == '-1') issue.assignee = ComponentAccessor.getUserUtil().getUser('someuser') {code}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've turned off Unassigned as a selection in the Assignee dropdown, and now would like to assign to the reporter if Automatic is chosen or left by default. I have tried to use the code talked about here in my groovy script:
webwork.action.ActionContext.getRequest().getParameter("assignee")
but the value is always null, regardless of whether I choose Automatic or an actual user. What am I doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ran into this as well - looks like there's a bug in the wrapper. Here's how I worked around it:
String assigneeFormValue = ((String[])webwork.action.ActionContext.getRequest().getParameterMap().get("assignee"))[0];
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.