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.
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 @PD Sheehan , thanks for the corrections and your quick response.
This helps me a lot! :)
Have a nice day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.