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() )

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

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
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,300 views 12 19
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