Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,198
Community Members
 
Community Events
184
Community Groups

Automatically assign to a user from a custom field

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.

Test Lead screenshot.JPG

Please can someone suggest how I can get this into the workflow?

2 answers

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2023

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 ? 

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 01, 2023

Hi @Ashley Roberts 

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.

Sorry, that should have read "custom field" not "customer field".

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 02, 2023

@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?

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.

Test Lead screenshot2.JPG

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2023

@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 SummaryDescription, 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)

Like Vikrant Yadav likes this

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 04, 2023

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')
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.13
TAGS
AUG Leaders

Atlassian Community Events