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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

condition to cascading field

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

2 votes
Answer accepted

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
}

 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Upgrading your Confluence Cloud for Microsoft Teams app

If you were upgrading the legacy app to our new one, you might have run into the error below while trying to authenticate. We're still investigating the cause of this but here's a workaround...

20 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you