I'm having an issue with a workflow and getting it to do what I want. I have set up an issue that has a custom project field selector. My goal is to have issue be assigned to the someone in the PM role of the project that is selected in the project selection custom field. I'm sure it's possible through some scripting, but I'm unfamiliar with JIRA's language. Any help is greatly appreciated.
Please try this script with necessary changes. Here,
) - Replace "customfield_Name" with your customfield name.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.user.util.DefaultUserManager import com.atlassian.crowd.embedded.api.User userManager = (UserManager) ComponentAccessor.getUserManager() MutableIssue issue = issue IssueManager issueManager = ComponentAccessor.getIssueManager() CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() CustomField mycustomfield = customFieldManager.getCustomFieldObjectByName("customfield_Name") def mycustomfieldValue = (ApplicationUser)issue.getCustomFieldValue(mycustomfield) issue.setAssignee(mycustomfieldValue)
This assigns the issue to the user mentioned as the customfield value.
Basically, you were using a Project selection field, but it carries PM user values. how did you configured those values to the custom field?
So, you manually added those selection values for the field. The project selection custom field's value is not user type. Is my understanding correct?
Sorry for not responding sooner, I'm apparently limited to 2 posts in 24 hours.
It's a Project Picker (single project) custom field, so I didn't manually add the projects. Yep, it's not a user type. There are post functions that allow you to assign the issue to the PM role, but that would be for the current project. I need to somehow get the PM role from that custom field and assign it that way. Hopefully that makes sense. Let me know if you need any more info.
Basically, you need to get the custom field value and convert it to user type based on multiple conditions. Then, it has to be assigned to that respective PM. Is my understanding right? If else, please explain the situation with an example including the field values.
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG