Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

set child.id based on parrentid in Cascading Select List with Behaviour

DKB Service GmbH December 22, 2020
Hey guys,
I'm not really a developer, but I have a requirement for a create issue screen that I would like to implement.
Unfortunately I could not find anything suitable on the www.

in the create issue screen i have a custom field (cascading select list) with the following values.

parentid:
- one time
- Every day
- weekly
- per month

childid:
- Set up archiving
- Task file transfer set up

i want to make some work easier for the user.

if selection parentid:
{"daily or" weekly "or" monthly"}
then childid:
{"Set up task file transfer"}

so the user has a predefined selection of the most frequently occurring value. however, he can change it manually

I hope you can help me

1 answer

1 vote
DKB Service GmbH December 23, 2020 edited

seems i found a solution:

// Write this behavior on field Archivierungsdauer(Cascading Select List field)

import com.atlassian.jira.component.ComponentAccessor

def crField = getFieldById(getFieldChanged())
def selectedOption = crField.getValue() as String

// det the cascading select field
def fieldName = "Archivierungsdauer"

//Parent value you want to select (Cascade select list) parent)
def parent1 = "einmalig"
def parent2 = "täglich"
def parent3 = "wöchentlich"
def parent4 = "monatlich"

// child value that you want to select (Cascade select list child)
def child1 = "Archivierung einrichten"
def child2 = "Zusätzlichen FBIA Task Filetransfer einrichten"

//Get Cascade select List field
def field = getFieldByName(fieldName)
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(fieldName)
def fieldConfig = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)

// Select the value of form field value (Select list field)

if (selectedOption.contains("einmalig"))
{
//Set einmalig default values
def parentOption = options.find {it.value == parent1}
def childOption = parentOption?.childOptions?.find {it.value == child1}

field.setFormValue([
parentOption.optionId,
childOption.optionId
])

}
else if (selectedOption.contains("täglich"))
{
//Set täglich default values
def parentOption = options.find {it.value == parent2}
def childOption = parentOption?.childOptions?.find {it.value == child2}

field.setFormValue([
parentOption.optionId,
childOption.optionId
])
}
else if (selectedOption.contains("wöchentlich"))
{
//Set wöchentlich default values
def parentOption = options.find {it.value == parent3}
def childOption = parentOption?.childOptions?.find {it.value == child2}

field.setFormValue([
parentOption.optionId,
childOption.optionId
])
}
else if (selectedOption.contains("monatlich"))
{
//Set monatlich default values
def parentOption = options.find {it.value == parent4}
def childOption = parentOption?.childOptions?.find {it.value == child2}

field.setFormValue([
parentOption.optionId,
childOption.optionId
])
}
else {
return
}

 if i start create issue the first lection af a parrent value and autom. set the child value works..

BUT:

if ich change the parrent value to another, both values are changing the value continuously.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events