Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Script Runner Create Sub-Task Condition Code Issues


So I've been working to add a post function to a workflow that will create a sub-task if condition is met in a specific cascading select custom field. I've placed a simple condition into the create a sub-task post function. However, upon testing of the post function in a test issue I'm receiving the following error:

java.util.NoSuchElementException: Cannot access first() element from an empty List


 I don't have the exact code available at this time but it follows the structure shown in the ScriptRunner snippets drop down and contains multiple or (" || ") operators to cover all of the field combinations being looked for, so it's like this:


cfValues['Field Name 1']?.values()*.value == ['Parent','Child'] || cfValues['Field Name 2']?.values()*.value == ['Parent','Child'] || cfValues['Field Name 3']?.values()*.value == ['Parent','Child'] ||...continuing for multiple custom fields


Any assistance with this would be greatly appreciated, thanks.

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 14, 2022

Hi @Glenn Edwards

The code snippet doesn't appear to be correct.

In the validator, the cfValues function implicitly extracts the values from the field. So when you use

cfValues['Field Name 1']

 it is equivalent to using 

def customFieldManager = ComponentAccessor.customFieldManager

def field1 = customFieldManager.getCustomFieldObjectsByName('Field Name 1').first()

def field1Value = issue.getCustomFieldValue(field1) 

 So, there is no need to call an additional values() method from it as you have done:-

cfValues['Field Name 1']?.values()*.value == ['Parent','Child'] 

You can instead use

cfValues['Field Name 1'] in ['Parent','Child'] ||  cfValues['Field Name 2'] in ['Parent','Child'] || cfValues['Field Name 3'] in ['Parent','Child']


Also, what type of validator are you using? Is it the Simple Scripted Validator or the Custom Scripted Validator?

I am looking forward to your clarification.

Thank you and Kind regards,


Hello @Ram Kumar Aravindakshan _Adaptavist_ and thank you for the assistance. My apologies for my original post not being as clear (I've cleared that up in an edit). The script is being used as the condition for a ScriptRunner Creat a sub-task post function.


Your suggested updates to use "in" instead of values() did clean up the errors. However, even though there aren't any errors, I'm not seeing the creation of the sub-task or any errors in the atlassian-jira.log. Any thoughts as to what may be occurring here?

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 14, 2022 • edited

Hi @Glenn Edwards

Since you are using the Post-Function, could you please clarify if you are using the Create sub-task [ScriptRunner]  or a Custom script post-function [ScriptRunner]

If it is the former, please share a screenshot of your configuration and if there are additional conditions to your code, kindly include them as well. If it is the latter, share your code.


Thank you and Kind regards,


Hi @Ram Kumar Aravindakshan _Adaptavist_


I'm using the Create sub-task [ScriptRunner] functionality for the post function.Though I'm unable to provide a screenshot I will transcribe the 8 Post Functions that are present (the first 5 being the automatic system post functions).


  1. Set issue status to the linked status of the destination workflow step.
  2. Add a comment to an issue if one is entered during a transition.
  3. Update change history for an issue and store the issue in the database.
  4. Re-index an issue to keep indexes in sync with the database.
  5. Fire a Issue Resolved event that can be processed by the listeners.
  6. Update Any Issue Field (JSU)
    • Issue Field: Jump to Resolve
    • Field Value: 14604
  7. Create a sub-task: Sub-task will be created with issue type: Sub-task (condition applies)
  8. Fast-track transition an issue: Action: Custom Field (131) will be applied. Note that this should go after the Fire Event function.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events