Cascading select list and making 2nd value mandatory

Rafal Sojka December 10, 2020

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
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.
December 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  

Rafal Sojka December 11, 2020

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
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.
December 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.

Rafal Sojka December 13, 2020

Ok, thank you!

Suggest an answer

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

Atlassian Community Events