I been having a hard time finding out why this is not working. I am trying to get the custom field value of "Affected User" which is a user picker field.
Here's my groovy script.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.customfields.manager.OptionsManager def componentManager = ComponentManager.instance def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) def customFieldManager = componentManager.getCustomFieldManager() def type = issue.getIssueTypeObject().getName() def summary = issue.getSummary() def cf1 = customFieldManager.getCustomFieldObjectByName("Affected User") def user = issue.getCustomFieldValue(cf1)
The type and summary works fine when I run it in the script runner with the following code:
def componentManager = ComponentManager.getInstance() def issue = componentManager.getIssueManager().getIssueObject("ACR-42")
I get the following results with script runner:
com.atlassian.crowd.embedded.ofbiz.OfBizUser@c2c49b46
Any idea why I can't actually retrieve the user name?
The actual user name (not the User object) should be:
issue.getCustomFieldValue(cf1).name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Eugene Domingo you have used this script for Listener or Behavior?
Because when i am using it in listener , i am getting error for static type checking error "def issue = customFieldManager.getIssueManager().getIssueObject("ACR-42")"
below i have pasted the code.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def componentManager = ComponentManager.getInstance()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
//IssueManager issueManager = ComponentAccessor.getIssueManager();
def issue = customFieldManager.getIssueManager().getIssueObject("ACR-42")
def type = issue.getIssueTypeObject().getName()
def summary = issue.getSummary()
def cf1 = customFieldManager.getCustomFieldObjectByName("Impacted Application/s")
def user = issue.getCustomFieldValue(cf1).getName()
Regards
Manas
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.