Hi,
I'm working in JSD and would like both Category (Hardware, Software, Network, etc) and Subcategory (Mouse, Disk, Harvest, Jira, VPN, etc.) to be required (easy, I got this part using configuration). I would with only like certain values to be available for selection in Subcategory when a Category value is chosen. Unfortunately, Select List (cascading) won't work, as when it's made required, the condition is satisfied with only a single value selected. In other words, it's ok with the user only selecting 'Software', but not the subcategory value.
I have just installed ScriptRunner in hopes of a fast solution, but as I'm a complete novice to it, it's quite a challenge. Your suggestions would be much appreciated!
Thanks!
Just in case anyone's checking. I got it figured out based on someone else's post (which I unfortunately lost). Add the following to Server script to the Category field:
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def allowedOptions = null
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def typeofSubcategoryCustomField = customFieldManager.getCustomFieldObjectByName("Product Subcategory")
def fieldConfig = typeofSubcategoryCustomField.getRelevantConfig(issueContext)
def category = getFieldByName("Product Category")
def categoryValue = category.getValue()
def typeOfSubcategory = getFieldByName("Product Subcategory")
if (categoryValue.toString() == "Hardware"){
allowedOptions = optionsManager.getOptions(fieldConfig).findAll() {
it.value in ["None","Mouse", "Monitor", "CPU"]
}
}
else if (categoryValue.toString() == "Network") {
allowedOptions = optionsManager.getOptions(fieldConfig).findAll() {
it.value in ["None","VPN", "IP Address","Wireless"]
}
}
else if (categoryValue.toString() == "Software") {
allowedOptions = optionsManager.getOptions(fieldConfig).findAll() {
it.value in ["None","Ticketing (Siebel)", "Ticketing (Jira Service Desk)","Time tracking (Harvest)","Billing (Kenan)","Billing (GBS)"]
}
}
else {
allowedOptions = optionsManager.getOptions(fieldConfig).findAll() {
it.value in ["None","VPN", "IP Address"]
}
}
typeOfSubcategory.setFieldOptions(allowedOptions)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.