You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi,
I need to show different values for same field based in the issue type.
From as I know, this can be done using Behaviors.
Jira Field:
Service and Sub-category - Is field is a cascade option.
Field options:
Service1 - 1 Sub 1
Service1 - 1 Sub 2
Service2 - 1 Sub 1
Service2 - 1 Sub 2
Service3 - 1 Sub 1
Service3 - 1 Sub 2
Context created:
Project = TESTSD
All issue types
What I need:
Issue type "Support"
must show only the options:
Service1 - 1 Sub 1
Service1 - 1 Sub 2
Service2 - 1 Sub 1
Service2 - 1 Sub 2
Issue type "BUG"
must show only the options:
Service3 - 1 Sub 1
Service3 - 1 Sub 2
Note 1 - this is to user in Service Desk
How can i do this? Can you help?
Thanks in advance
@Humberto Gomes, can you please clarify, should this be shown on the customer portal? Or is this on the agent side?
Thanks!
Kian
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.
@Humberto Gomes,
Try something like this!
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.priority.Priority
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customerSelectField = getFieldByName('Service and Sub-category')
def customField = customFieldManager.getCustomFieldObject(customerSelectField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionMap = [:]
optionMap.put("-1", "None")
if (issueContext.issueType.name == "Support") {
optionMap += options.findAll {it.value in ['Service1', 'Service2']}.collectEntries {[(it.optionId.toString()): it.value]}
}
else if(issueContext.issueType.name == "Bug"){
optionMap += options.findAll {it.value in ['Service3']}.collectEntries {[(it.optionId.toString()): it.value]}
}
customerSelectField.setFieldOptions(optionMap)
I did some testing with this and it appears to be working for me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kian Stack Mumo Systems Thanks for your time.
What i'm doing wrong here?
Behaviour:
Field options:
Mapping:
Code:
Service desk:
IF I Change the mapping to:
The problem is the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmmm. I'm not sure on that one. What version of Jira are you using?
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.
Hi,
This is the final code and it's working:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def issueType = issueContext.getIssueType().getName()
def cascadingCustomField = customFieldManager.getCustomFieldObjects().findByName("Service and Subcategory")
def cascadingFormField = getFieldByName("Service and Subcategory")
def fieldConfig = cascadingCustomField.getRelevantConfig(issueContext)
def options = optionsManager.getOptions(fieldConfig)
// Get the parent's ID
def parentA_ID = options.find
{ it.value == 'A' }
.getOptionId()
def parentB_ID = options.find
{ it.value == 'B' }
.getOptionId()
def parentC_ID = options.find
{ it.value == 'C' }
.getOptionId()
// Set the parent's options
Map option1 = [:]
option1.put ("-1", "None")
option1.putAll([(parentA_ID) : "A" , (parentB_ID) : "B"])
Map option2 = [:]
option2.put ("-1", "None")
option2.putAll([(parentC_ID) : "C"])
// Set available options based on Issue Type
if (issueType == "Bug")
{ cascadingFormField.setFieldOptions(option1) }
else if (issueType == "Support")
{ cascadingFormField.setFieldOptions(option2) }
Thanks for all support.
I'm tagging this as the Accept Answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there,
You can check out ScriptRunner's Library of the two below:
The idea of setting normal Select List or Cascading Select List field options are the same as given in the above links.
Other than that, do take note that there are two types of Behavior's mapping:
If you are trying to use it in Customer Portal, make sure you use the Service Desk mapping and map it to the appropriate Request Types.
Cheers~
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan. &nb...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.