You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am trying to have issues assigned to a user that is in a customer field when an issue reaches a certain state in a workflow.
I have looked at adding a post function and I can see an option to use. I have looked at "Copy field values" and I can select the source field but can select the Assignee field in the target field.
As shown in the screenshot.
Please can someone suggest how I can get this into the workflow?
Hi @Ashley Roberts I think you are using Script Runner Copy Field value post function. This post function won't support Assignee and Reporter field.
Kindly create a scripted post function for this. Test lead is user picker custom field ?
Can you please explain what do you mean by "customer"? Usually a customer can be found on JSM projects. And you can't really assigned anything to a customer, unless this customer has a valid JSM license and has the "assignable" permission.
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.
@Ashley Roberts hi!
Thanx for the clarification. So you want to copy the assignee onto a custom field, or vice versa? Which post function do you use?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was thinking of using "Copy field values from one field to another"
I can get the custom field showing in the source field, but I can't get the Assignee field to show in the Target Field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vikrant Yadav has a keen eye, and you are indeed using Scriptrunner. Based on their documentation:
All text and select custom fields are supported, as well the the Summary, Description, and Environment system fields.
https://docs.adaptavist.com/sr4js/6.31.0/features/built-in-scripts/copy-field-values
So in other words this post function will not let you copy the field to assignee. Do you have another app to use like JMWE? If not, then use the custom script from scriptrunner and try to follow the instructions on this post https://community.atlassian.com/t5/Jira-questions/Script-to-copy-Assignee-field-to-other-userpicker-custom-field/qaq-p/1061704 (but in reverse)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have created the following script in Scriptrunner but it does not work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def assigneeField = ComponentAccessor.getFieldManager().getFieldByName("Assignee")
def customField = customFieldManager.getCustomFieldObjectByName("Test Lead")
issue = event.issue as MutableIssue
def user = issue.getCustomFieldValue(customField) as ApplicationUser
if (user && issue.getStatusObject().getName() == "Awaiting Closure") {
issue.setAssignee(user)
}
ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue ****** for user '*****'. View here: https://************/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=*******Workflow&descriptorTab=postfunctions&workflowTransition=61&highlight=1
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.DefaultFieldManager.getFieldByName() is applicable for argument types: (String) values: [Assignee]
at Script15.run(Script15.groovy:6)
Sorry, due to the nature of where I work, I need to redact some of the information out of the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is because assignee is not a field, its part of the issue.
You can use issue.getAssignee() and issue.setAssignee(Application-user) to work with it.
Or, if you aon a recent version of Scriptrunner, one with HAPI in it, something like the below (which needs no imports)
Issues.getByKey('SR-1').update {
setAssignee('jdoe')
}
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.