Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,465,131
Community Members
 
Community Events
176
Community Groups

Behaviour based on preset value in SD form

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?

1 answer

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:-

behaviour_config-1.png

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.

test1.png

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.

test2.png

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.

test3.png

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) 

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

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events