condition to cascading field

Sergio Palacio April 24, 2018

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.

Captura3.PNG

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
2 votes
Answer accepted
Neta Elyakim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 30, 2018

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
}

 

TAGS
AUG Leaders

Atlassian Community Events