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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

240 views 5 13
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