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

1 vote

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

0 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

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