I have an issue-type of "Task" and it shares the same workflow as bug, epic and story.
I have this cascading field and i only want both fields (in cascading CF) to be required only in Task issue type not in bug, story and epic.
I have a piece of code that i added as a validator on create (workflow).
i managed to resolve this by using the following script
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.INFO)
if (issue.issueType.name == 'Issue-type') {
def cascadingSelect = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find{ it.name == "cascading_field" }
def values = issue.getCustomFieldValue(cascadingSelect) as HashMap if (values?.keySet() != null && values?.keySet()?.size() == 2) {
for ( String k : values?.keySet() ) {
if ( k == 'null' ) return false
}
return true
}
return false
}
Use different field configurations.
Yes, as long as it is a different issue type. Required fields, at creation time are controlled by the field configuration scheme. That scheme is composed of one or more field configurations. Every issue type can have its own field configuration inside the field configuration scheme. If you have 5 issue types and 1 has special needs you create a field configuration for the 4 issue types and another for the 1 issue type. Then you combine them into a field configuration scheme and apply that to the project. When an issue is created, it looks for a field configuration for that issue type and uses it. If it doesn't find one it uses the default in the configuration scheme. Copy/paste this link for more information. https://confluence.atlassian.com/adminjiracloud/configuring-a-field-configuration-scheme-844500805.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Joe Pitt
I have the field required for Task issue-type using Behaviours.
I then created a validator on the workflow.
this is my script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
if (issue.issueType.name == 'Task') {
def Issue = issue as MutableIssue
def cascadingSelect = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)?.findByName("Classification")
def values = issue.getCustomFieldValue(cascadingSelect) as HashMap
// Will return true if both the parent and child options in the Cascading Select have a value
values?.keySet()?.size() == 2
}
the script works fine for issue-type "Task".
The problem I have is that for some issue-types like bug, when I create an issue the complain about the missing values on the classification field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.