Hi Community,
looking for the solution for one of my clients.
They would like to have a Custom user user picker called "Requestor" have prepopulated with currentUser when they open the Create screen.
We got Behaviors available, but I am not able to make it work.
Can you hint me guys pls?
Cheers, Tom
Something like...
import com.atlassian.jira.component.ComponentAccessor
if (getActionName() == "Create Issue") {
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get the Requestor field
def requestor = getFieldByName("Requestor")
requestor.setFormValue(currentUser.key)
}
** not tested, wrote from memory.
Or maybe just set the field the same as reporter (assuming they can't change the field on Create)
They can do change on the create.
The point behind this is to not disturb user by filling this, if they are requesting on their own behalf, but give them option to change that, if they are requesting on behalf of someone else.
Will try this one, not skilled with this level of scripting at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@JiraJared solved with slightly modified code
import com.atlassian.jira.component.ComponentAccessor
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get the Requestor field
def requestor = getFieldById("customfield_10301")
if (requestor.formValue == "") {
requestor.setFormValue(currentUser.key)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.