Hi,
I would like to find a way using AdaptavistScript Runner how to set a Custom User Picker Field after selecting an Option from a Select List (Single Choice) when creating an issue.
Example: If I choose Product A, I would like the Product Owner to be username1
Can someone please give some tips on how I can set this up?
Cheers
Here is code example for your case. I did not tested it, but it should work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.Option
String userName;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
switch(((Option) issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Select List"))).getValue()){
case "Option 1": userName = "user 1";break;
case "Option 2": userName = "user 2";break;
case "Option 3": userName = "user 3";break;
}
issue.setCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Custom User Picker Field")
, ComponentAccessor.getUserManager().getUserByName(userName) )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the context where you are running this, eg a post-function? A screenshot of the whole page would help here.
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.