Community moderators have prevented the ability to post new answers.
To add on to Kristian's answer, it is possible to set the default value for a custom user picker field using Behaviours as well.
The main benefit of using a behaviour instead of a post-function on the create transition is that the end user will be able to see and make an informed change to the user picker field. Doing the script on the post-function can be a little opaque; the user leaves validating user blank, and only sees it populated after they submit the new issue.
If the user you want to set it to is always the same one, you could simply put their username in the setFormValue method of an initialiser function:
def validatingUser = getFieldByName("Validating User") validatingUser.setFormValue("johnson")
If it needs to be more dynamic, you could use classes like the UserService and UserSearchService to find the appropriate user and get their username.
Hi Jonny,
I cannot able to change default username like johnson, its populating default one when tired to change it.
It would be like user can change Validating User field or if not leave it as default Johnson.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Teju,
This requirement does not need script runner and can be completed by installing the JIRA Suite Utilities plugin and using a Copy Custom Field Post function that is placed as the last post function on the create transition.
The post function would be configured similar to the screenshot below and would copy the value from the Reporter field to the Validating User field.
Screen Shot 2016-12-22 at 12.11.42.png
Unfortunately you could not set a user picker field to have a value which is not a user object. If you want to set it to a name such as a users full name then you would need to use a script similar to below which would set a single line text field.
// Required Import Statements import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue // Get a pointer to the issue MutableIssue issue = issue // Get the current Issue MutableIssue SubjectIssue = issue // Get a pointer to the Custom Field Manager def customFieldManager = ComponentAccessor.getCustomFieldManager() // Get the value of the Full Name Scripted Field def validateUserCN = SubjectIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Validating User Common Name")) // Get the reporter value def reporter = SubjectIssue.getReporter().name.toString() // Check if the reporter field contains a value if(reporter !=null){ // Set the Validating user field with the value of the reporter field SubjectIssue.setCustomFieldValue(validateUserCN, reporter); }
I hope this helps.
Thanks
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.