Hi,
I have a single-select field appName withs option BRI, CA, DM). And another single-select field ipName (options BRI 1, BRI2, CA 1, CA 2, DM 1 and DM 2)
I have 3 request types, namely BRI, CA and DM which have preset value for appName accordingly.
If a user raise a request, for example for CA, I only want to show CA1 and CA 2 for ipName field drop down. Same for BRI and DM
Is this possible?
Hi @Joel Batac
This is a common question that has been asked several times in the community.
I will show you an example tested on the Service Desk. Below is the sample code for your reference:-
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def appName = getFieldById(fieldChanged)
def appNameValue = appName.value.toString()
def ipName= getFieldByName('IP Name')
def customFieldManager = ComponentAccessor.customFieldManager
def optionManager = ComponentAccessor.optionsManager
def ipNameCustomField = customFieldManager.getCustomFieldObject(ipName.fieldId)
def availableConfig = ipNameCustomField.getRelevantConfig(issueContext)
def ipNameOptions = optionManager.getOptions(availableConfig)
def availableOptions = [] as ArrayList<String>
if (appNameValue == 'BRI') {
availableOptions = ['BRI1', 'BRI2']
} else if (appNameValue == 'CA') {
availableOptions = ['CA1', 'CA2']
} else if (appNameValue == 'DM') {
availableOptions = ['DM1', 'DM2']
}
def availableOptionsMap = ipNameOptions?.findAll {
it.value in availableOptions
}
ipName.setFieldOptions(availableOptionsMap)
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Behaviour configuration:-
I also include a couple of test screenshots for your reference:-
1. If I am to select the BRI option from the App Name list, the options in the IP Name list are filtered accordingly to BR1 and BR2.
2. Similarly, if I am to select the CA option from the App Name list, the options in the IP Name list are filtered accordingly to CA1 and CA2.
3. Finally, if I am to select the DM option from the App Name list, the options in the IP Name list are filtered accordingly to DM1 and DM2.
Note: The None option cannot be removed. Even if the options from the IP Name list are filtered, the None option will still be displayed. This is an expected Behaviour.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
Thanks Ram. I know this way, what I was asking was if i preset the value of App Name in the form (hidden from users and not selecting from drop down)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Joel Batac,
In your last comment, you mentioned:-
I know this way, what I was asking was if i preset the value of App Name in the form (hidden from users and not selecting from drop down)
Could you please clarify exactly when do you want the preset value for the App Name field to be set and on what condition you want to control the option set for the App Name field? Is it based on the Issue Type?
I am looking forward to your clarification.
Thank you and Kind regards,
Ram
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.
So basically in the form, I preset the value of Application to BRIE if the request type is BRIE. I want this preset value as the basis/trigger for behaviour for the IP Name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.