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?
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Get object for custom field like that:
CustomField cstFld_getTime = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("customFieldName")
Get value for sertain issue and check for null
if(issue.getCustomFieldValue(cstFld) == null){ // actions if null } else{ //actions if not null }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use Script postFunction provided ScriptRunner plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.