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,560,601
Community Members
 
Community Events
185
Community Groups

Behavior Plugin - Add an addtional value to a drop down based on another field vale

can someone share a sample script to add a value to a dropdown based on value selected in another field

 

I need to add an additional value 'Existing Prod Value' to a field Dev RCA when 'Detected in Test Stage' is NOT Warranty or Prod

1 answer

1 accepted

0 votes
Answer accepted

The script in here will show you how to list different options for single select list field based on selection from other list field.

You can try to add new option to the list and test if its saved. I am not sure about that part.

https://community.atlassian.com/t5/Adaptavist-questions/Behavior-script-for-field-dependecy/qaq-p/1304574

thanks @Jiri Kanicky 

Can you please let me know why this is not working for me? Also I want to set None as the default value.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager

//Get Relevant field and options manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def detectedinteststageField = getFieldById(getFieldChanged())
def selectedOption = detectedinteststageField.getValue() as String
def cfDevRCA = getFieldById("customfield_18408")

def customField = customFieldManager.getCustomFieldObject(cfDevRCA.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

if(selectedOption != "5-Warranty" || selectedOption != "7-PROD"){
def optionsMap = options.findAll {
it.value in ["None", "Ambiguous requirement" , "Code merging" , "Data quality issue" , "Design documentation issue - E2E sheet" , "Design gap - FDD" , "Design gap - TDD" , "Developer Oversight" , "Existing prod issue" , "Impact not analysed - Cross project impact" , "Impact not analysed - Incomplete analysis" , "Impact not analysed - Regression/Defect fix" , "Improper reconciliation" , "Incomplete implementation/defect fix in ST/UAT/Prod" , "Incorrect configuration" , "Incomplete implementation" , "Incorrect logic" , "Incorrect solution" , "Induced due to PRS" , "Interface changes/mismatch" , "Lack of system understanding" , "Package issue" , "Retrofit missed" , "Scenario coverage/Incomplete unit testing"
] // list of options you want to show
}.collectEntries {[(it.optionId.toString()): it.value]}
cfDevRCA.setFieldOptions(optionsMap)
}
else{
def optionsMap = options.findAll {
it.value in ["None", "Ambiguous requirement" , "Code merging" , "Data quality issue" , "Design documentation issue - E2E sheet" , "Design gap - FDD" , "Design gap - TDD" , "Developer Oversight" , "Impact not analysed - Cross project impact" , "Impact not analysed - Incomplete analysis" , "Impact not analysed - Regression/Defect fix" , "Improper reconciliation" , "Incomplete implementation/defect fix in ST/UAT/Prod" , "Incorrect configuration" , "Incomplete implementation" , "Incorrect logic" , "Incorrect solution" , "Induced due to PRS" , "Interface changes/mismatch" , "Lack of system understanding" , "Package issue" , "Retrofit missed" , "Scenario coverage/Incomplete unit testing"
] // list of options you want to show
}.collectEntries {[(it.optionId.toString()): it.value]}
cfDevRCA.setFieldOptions(optionsMap)
}
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 25, 2020

Hi @Vidhya Mohan,

Couple of things on this

1. you want this change should happen if the selected option is neither  Warranty nor Prod right? then the condition should be 

if(selectedOption != "5-Warranty" && selectedOption != "7-PROD")

2. "None" is not a option unless you created one for that field. it is empty value provides by system. if you leave that part system will always fill the form field with None(if there is no default value is configured). it's better to remove that option from your script

 3. without  checking apart from None option looks good to me. do you get any error? if so can you pass me the same to check 

 

Note:  Remove // list of options you want to show I just added to explain that part in my previous script

 

BR,

Leo

Hello @Leo 

 

thanks. this worked. But issue is it always selects 'Ambiguous requirement' as the default value. How to get this changed? I want either blank or None as the default value. 

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 26, 2020

Hi @Vidhya Mohan,

Check the configuration of that field and remove default value configured for the same

 

BR,

Leo 

@Leo 

Default Value is set as none  :( 

Default Config.png

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 26, 2020

You can try this method, I haven't tried by myself but hopefully this should do what you are looking for

cfDevRCA.setFieldOptions(optionsMap + ["-1": "None"])

Thank you @Leo . It worked

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events