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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,237
Community Members
 
Community Events
185
Community Groups

ScriptRunner Validator - Subtasks have Select CF initialized

Hello,

Im trying to make a validation in a transition where the parent check if all the sub-tasks have a cf: select list, initialized with a value.

Actually I have done this:

import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("UO type")

if (! issue.isSubTask()) {
return true
}

def selectedValue = issue.getCustomFieldValue(cf) as Option
issue.subTaskObjects.every {selectedValue != null}

-> But its not working.

Thanks in advance.validator.png

 

1 answer

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 23, 2021 • edited

The issue is in your last 2 lines.

selectedValue is specific to the parent issue, attempting to check this for a null value in the every{} block is not achieving what you think.

Here is the complete logic that you are trying to accomplish if I understand correctly

issue.subTaskObjects.every{subTaskIssue->
def UOTypeValue = subTaskIssue.getCustomerFieldValue(cf)
UOTypeValue != null
}

 And it can be further simplified because of the built-in groovy truthiness

issue.subTaskObjects.every{it.getCustomerFieldValue(cf)}

Hello @Peter-Dave Sheehan , thanks for the corrections and your quick response.

This helps me a lot! :)

 

Have a nice day.

Like Peter-Dave Sheehan likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events