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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

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

Cascading select list and making 2nd value mandatory Edited

Dear Friends,

I have a cascading select list field

cascading select list example.pngin my project and when i make it mandatory in the field configuration only the 1st value is verified by JIRA. The 2nd value can be empty. It seems to be default behavior for this type of custom fields.

However, i need to go further and enforce that 2nd value is also mandatory. I managed to do this on Create screen by using ScriptRunner script validator in workflow. And it works fine on the Create screen, this is the code I wrote:

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import org.apache.log4j.Level
import org.apache.log4j.Logger

//def log = Logger.getLogger("com.acme.workflows")
//log.setLevel(Level.DEBUG)

CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager();
CustomField parentField = cfm.getCustomFieldObject("customfield_11000");

def cascadingListValue = issue.getCustomFieldValue(parentField) as Map
if(cascadingListValue != null){
String parent = cascadingListValue.get(null);
String child = cascadingListValue.get("1");

//log.info("Parent:" + parent);
//log.info("Child: " + child);

return ((parent != null) && (child != null));
} else
return false;

However, the challenge here is with the Edit screen. The Edit action is not associated with any transition, like Create action, and I am not sure if there is any way to force jira to validate that 2nd value is mandatory. Tried to do something with Behaviour but so far no progress here. 

If you have any ideas how to achieve this, please let me know. Any thoughts are welcome.

Thank you,

 

 

1 answer

0 votes
Liam Green Community Leader Dec 10, 2020

Hi @Rafal Sojka 

Whilst I'm not an expert in this area, could you achieve this by using your script to make it mandatory on transition?  I know that wouldn't solve your immediate problem of it not being filled on edit, it would mean an issue couldn't be resolved if the information was missing  

Thank you Liam, this is a good workaround. However, i wonder if there is any solution to enforce such behavior on the edit screen. This is a part of functionality that is missing here, at least this is how I see it :). 

Do you know if we can inject our own javascript code into custom fields as it was possible in the old jira versions ?

Best regards,
Rafal

Liam Green Community Leader Dec 11, 2020

Hi Rafal

If I'm honest, I'm not sure about that.  Hopefully someone on here will know the answer, or you could reach out to Atlassian directly.

Ok, thank you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

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