Hi.]
I want to create a condition script to validate if a cascading field are filled.
Following my simple code. if is true a linked issue will be created using scriptrunner
if (cfValues['Dpt']?.values()*.value == [null, null])
{
return true
}
But it have an error.
Here is a groovy code:
In this case, if the cascading field is empty return false if the field has value in both of the fields - then return true
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def customFieldValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Cascading field name"));
HashMap<String, Option> hashMapEntries = (HashMap<String, Option>) customFieldValue
if(customFieldValue != null){
Option parent = hashMapEntries.get(CascadingSelectCFType.PARENT_KEY)
Option child = hashMapEntries.get(CascadingSelectCFType.CHILD_KEY)
if(parent == null || child == null){
return false
}else{
return true
}
}else{
return false
}
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.