Update CustomTextfield with current log in user

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

This widget could not be displayed.

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)

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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

256 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you