Update CustomTextfield with current log in user

Pushparaj Bhaskaran August 26, 2013

Ok so here is the requirement . In my Create to Open workflow transition , I need to execute a script that will check for a selected option value . If the required option is selected then set a Custom text field value to current logged in user ,if not don't do anything . BTW the option custom field name is "CustomAction" and it has 3 options ie (Unlock,Reset,Create). If Unlock or Reset then only set the Text Value .

2 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 27, 2013

Seems clear, but I'm not sure what the question is. (If you're asking for someone to write the code for you, you could be out of luck - most people here would expect you to do it yourself and ask for help if you get stuck, not do the work for you)

Pushparaj Bhaskaran August 27, 2013

import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.ComponentManager
log.warn( "line 1" )
def currentUserName = ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName()
log.warn( "line 2" )
FormField hiddenfield = getFieldByName("HiddenStateField")
log.warn( "line 3" )
FormField UserAccountaction = getFieldByName("User Account action")
log.warn( "line 4" )
if(UserAccountaction.getFormValue() == 'Unlock Account' || UserAccountaction.getFormValue() == 'Reset Password')
{
log.warn( "line 3" )
log.warn( UserAccountaction.getFormValue() )
hiddenfield.setFormValue(currentUserName)
}

HiddenStateField is the TextField where I need it stored. Me using JIRA 5.1.2

0 votes
JamieA
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.
September 4, 2013

So what's not working? What field is the behaviour applied to?

Can you use the correct tag, ie behaviours plugin not script runner plugin...

Suggest an answer

Log in or Sign up to answer