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

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

Suggest an answer

Log in or Sign up to answer