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.
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.