Hello,
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.
Thanks!
-Dusty
Please try this script with necessary changes. Here,
customFieldManager.getCustomFieldObjectByName(
"customfield_Name"
) - 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.
I think the OP wants a script to get the selected Project object from the custom field, then get one of the users in the PM role in that project, then set the assignee to that user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Matt is correct on what I'm after. Is something like this possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the quick reply!
The custom field is actually a Project selection and I'm wanting to assign the issue to someone in the PM role of the project selected in that custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please provide an example on the field values and the situation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.