fast track transition issue based on user picker field

I'm trying to fast track a transition an issue based on a user picker having a value or not.

If the user picker is populated I want the transition to fire. If it's empty I don't.

Without any example for referencing a user picker I had a few guesses but no matter what I tried the transition would never occur. There was nothing in the logs so as far as I can tell there is no actual error.

 

What is the correct syntax for determining if a user picker has a value?

 

3 answers

1 accepted

This widget could not be displayed.

You can also do it using "Set field as a function of other fields" post-function of JIRA Workflow Toolbox plugin as I show in the screenshot:

Captura de pantalla 2016-02-12 a las 12.51.44.png

In this case transition "Assign Issue" will be executed if custom field "User Picker" hasn't a value, and transition "Start Progress" if the field is set.

Note that ^$ is regular expression for empty string, and .* is regular expression for a non-empty string.

This widget could not be displayed.
Vasiliy Zverev Community Champion Feb 10, 2016
  1. Get object for custom field like that:

    CustomField cstFld_getTime = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("customFieldName")
  2. Get value for sertain issue and check for null

    if(issue.getCustomFieldValue(cstFld) == null){
    //	actions if null
    }
    else{
    	//actions if not null
    }

 

 

Are you saying that I cannot use the script post function to do it and can only do it in a groovy script? If that's the case then I'm going to have to learn how to transition an issue in groovy.

Vasiliy Zverev Community Champion Feb 10, 2016

You can use Script postFunction provided ScriptRunner plugin

Yes but I would like to use "Fast-track transition an issue" which really isn't compatible with what you've posted.

What you've posted is more suited to  "Custom script post-function" which i'm hoping to avoid as I need to learn a whole lot more than just how to access a custom user picker.

Also i'm not sold on what you've posted working for a user picker anyway seeing as it's not just a simple field but an object.

 

This widget could not be displayed.

I figured it out after looking through the source code for script runner and doing some tests in script console.

The null conditions are as simple as

cfValues['User Picker'] == null // to check for empty
or
cfValues['User Picker'] != null // to check for populated

 

also cfValues['User Picker']?.toString() resolves to "TestUser(testuser)" (for a user called testuser) when populated and "null" when not populated.

With this syntax it could be used to check for a specific user.

 

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...

259 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