Default Values in User Picker Custom Field in Customer Portal

Alvin
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.
October 2, 2018

Hi Community, Is it possible to set default value in user picker custom field by the current user in customer portal? using behavior ?

Screenshot from 2018-10-03 11_29_58.pngI need to capture the current user on" Requested for " user picker custom field  like on the above "Raise this request on behalf of" system field.

 

I tried it using this behavior , place it on Initialiser, mapped to Service Desk Project, because I just want it to become a default value. but no luck, any chances? When I try to check the console in chrome (f12)

When user is admin account, it can capture the user and place on the field, but when the user is customer account, it returns this error

Screenshot from 2018-10-03 13_38_08.png

 

This is the code:

import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor

def requestorField = getFieldById("customfield_10385")

def currentUserName = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()
requestorField.setFormValue(currentUserName)

1 answer

0 votes
Suresh Srini May 24, 2022
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours

def superior = getFieldById("customfield_10600")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()

superior.setFormValue(currentUser)


I found above code and it populates jira login id. it works. However, I am looing to have default value as "last name, First name"

Suggest an answer

Log in or Sign up to answer