Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Assignee as a custom field value

Soporte Ferrovial August 30, 2018

Hi,

      I need to have the value of the assignee user on a Custom Field (in order to send Jemh notifications with this value on the From field).

      How can I set my custom Field with this value on asignation action?

 

Thank you in advance for your answers.

 

2 answers

1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2018

Hello,

You would need an add-on for it. For example, you could use the Power Scripts add-on:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

You could create a listener on the Assigned event with a code like this:

#{Custom field name} = assignee;
0 votes
Nir Haimov
Community Champion
August 30, 2018

With Scriptrunner, you can with listener, update customfield with current assignee once assignee set/changed.

Soporte Ferrovial August 30, 2018

Thank you.

Please, could you give us more detail about this option? (Which kind of listener to use and how to set it - if you have done before)

Nir Haimov
Community Champion
August 30, 2018

Go to "Add-ons" -> Script Listeners -> Add new item -> custom listener

In the field "Event" choose "issue assigned"

in "inline script" you have to write a groovy script that will update your customfield with the current assignee.

Soporte Ferrovial September 6, 2018

Hi,

    I'm using this groovy script:

 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor


def issue = event.issue as Issue
def CustomFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = CustomFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Assign User"}
def tgtField1 = CustomFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Assign User (Text)"}
// name of your custom field
def assignee = issue.assignee
// get assignee
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), assignee),changeHolder)
tgtField1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField1),issue.getCustomFieldValue(tgtField)),changeHolder)
// set value of custom field to assignee

 

Assig User is a User Picker custom field and Assig User (Text) is a Single Line Text custom Field

First part is correct, Assig User takes the right value, but I need to copy it on a text field, I'm sure the problem is on this part:

tgtField1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField1),issue.getCustomFieldValue(tgtField)),changeHolder)

 

I have tested it and if I change issue.getCustomFieldValue(tgtField) for "test", it works, please, could you help me with this? 

Thank you in advance.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 9, 2018

The second line fails because the text field expects text, and you're throwing a user object at it.

Try giving it the user's name as a string instead:

tgtField1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField1), assignee.getName() ),changeHolder)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events