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,559,293
Community Members
 
Community Events
184
Community Groups

Cascading list box not changing

Edited

Hi all. Faced the problem of updating the options of the custom field of the cascading list. We have a third party system that contains a directory:
- Parent 1
-- child 1
-- child 2
- Parent 2
-- child 1
We update the custom field through the Scriptrunner, below is part of the update code. 

def issue = ComponentAccessor.issueManager.getIssueObject('OTHER-205')
CustomField PROGRAM_FIELD_NAME = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10244")
def om = ComponentAccessor.optionsManager
def options = om.getOptions(PROGRAM_FIELD_NAME.getRelevantConfig(issue))

def programs = Config.serviceDeskClient.sendGetRequest()
def temp = new HashMap<String, Program>(programs)

programs.entrySet().each {
def currentOption = options.find { op -> op.value.startsWith(it.key) }
if (currentOption.collect().size() == 1) {
currentOption.setValue(it.value.name)
it.value.subPrograms.each { sub ->
def currentChild = currentOption.childOptions.find { ch -> ch.value.startsWith(sub.key) }

if (currentChild.collect().size() == 1) {
currentChild.setValue(sub.value.name)
} else {
om.createOption(PROGRAM_FIELD_NAME.getRelevantConfig(issue), currentOption.optionId, (long) (currentOption.childOptions.size() + 1), sub.value.name)
}

}
} else {
om.createOption(PROGRAM_FIELD_NAME.getRelevantConfig(issue), null, (long) (options.childOptions.size() + 1), it.value.name)
}
}
om.updateOptions(options)
options.each {
log.error "${temp.containsKey(it.value.substring(0, 3)) && !Character.isDigit(it.value.substring(4, 5).charAt(0))}"
if (temp.containsKey(it.value.substring(0, 3))
&& !Character.isDigit(it.value.substring(4, 5).charAt(0))) {
it.childOptions.each { ch ->
if (!programs.get(it.value.substring(0, 3)).subPrograms.containsKey(ch.value.substring(0, 6))
|| !temp.get(it.value.substring(0, 3)).subPrograms.containsKey(ch.value.substring(0, 6))) {
om.disableOption(ch)
om.deleteOptionAndChildren(ch)
} else {
temp.get(it.value.substring(0, 3)).subPrograms.remove(ch.value.substring(0, 6))
log.error "Exception return"
return
}
}
} else {
log.error "DIASBLE OPTION ${it.value}"
om.disableOption(it)
om.deleteOptionAndChildren(it)
temp.remove(it.value.substring(0, 3))
}
}
om.updateOptions(options)

As a result, we get the following picture.
1. In the general list of options, a new value. pic 2pic2.png

2. In option edit mode, the old value. pic 3pic3.png
3. In the "view" task, the old value. pic 4pic4.png
4. In the task to "edit" the new value. pic 5pic5.png

The database stores the old value. Tried to index task/project/full reindex. A full reindex returns the old value.

Maybe someone faced similar?

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 26, 2023

Hi @boris_samoylov

Could you please clarify if you are trying to do this via ScriptRunner Behaviour or Listener or Post Function?

If it is via Behaviour, then the approach doesn't seem to be correct. Could you also pleases share a screenshot of your Behaviour configuration if you are doing this via Behaviour?

Also, what version of Jira and ScriptRunner are you using?

Thank you and Kind regards,

Ram

Good afternoon. This is done via REST Endpoints. The logic is such that a third-party service, while updating options on its own, sends a request to Jira and Jira already receives data for new options from a third-party service and edits its own.

This is done in order to update the data in the Jira as quickly as possible and so that the third-party service understands that the data in the Jira has been updated.

Jira Version 8.22.3 DC
Version Scriptrunner 8.0.0

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events