Set default field value for user picker field dynamically in JIRA

Sergey Shmarkatyuk
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.
March 18, 2013

I would like to set default value of user picker field as a current user.

What I'm trying to do is to attach following behaviour to the field I want to initiate with default value:

import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.ComponentManager

def requestorField = getFieldByName('Requestor')

def currentUserName = ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName()
requestorField.setFormValue(currentUserName)

But it does not work for some reason.

Is there any way to do that? Maybe I'm doing something wrong in my script?

Thanks

4 answers

1 accepted

0 votes
Answer accepted
Sergey Shmarkatyuk
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.
March 18, 2013

False alarm. Problem appeared to be with the behaviour mapping.

1 vote
Andris Bērziņš
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.
March 18, 2013

Just a guess - have you tried setting the field's value to User object instead of String, that is, remove the ".getName()" part?

Sergey Shmarkatyuk
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.
March 18, 2013

already tried this. it didn't help

Andris Bērziņš
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.
March 18, 2013

Hehe, i was stabbing in the dark anyway :) Glad you got it resolved

Andris Bērziņš
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.
March 18, 2013

Second guess: replace single quotes with double quotes?

Sergey Shmarkatyuk
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.
March 18, 2013

Andris, thanks for your prompt reaction. Issue has been resolved.

0 votes
Sergey Shmarkatyuk
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.
March 18, 2013

sorry, it turned out to be related to behaviour mapping

0 votes
JamieA
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.
March 18, 2013

What you have should work - looks ok to me anyway... What version of jira, version of plugin?

Suggest an answer

Log in or Sign up to answer