The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to use Behaviours plug-in to auto-fill a custom field with the current user at creation.

Rachel Casali
December 18, 2019

We have a field called "Incident Owner" that we want to pre-populate with the current user's name on the create screen. 

We have Adaptivist's Behaviours plug-in, but I'm having difficulty putting together an Initialiser that works. 

Any help would be much appreciated!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
brbojorque
Community Champion
December 18, 2019

Please try this and let me know if it works.

import com.atlassian.jira.component.ComponentAccessor

def incidentOwner = getFieldById("customfield_12345")

def
 currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

incidentOwner.setFormValue(currentUserObj.name)
Rachel Casali
December 19, 2019

That did it! Thank you so much!

Like Andrew Zimmerman likes this