You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
def formFieldA = getFieldByName('fieldA')
def formFieldB = getFieldByName('fieldB')
def map = [
'A':['Monday', 'Wednesday'],
'AB':['Monday', 'Tuesday']
]
def cfFieldB = customFieldManager.getCustomFieldObject(formFieldB.fieldId)
def config = cfFieldB.getRelevantConfig(issueContext)
def allOptions = optionsManager.getOptions(config)
def optionsToAllow = allOptions.findAll{ option->
map[formFieldA.value].contains(option.value)
}
formFieldB.setFieldOptions(optionsToAllow)
I have this script which is working fine.. select list changing multi slect.
What i should change here to have multiselect change multi slect?
Please let me know
Have you put some thought into how you want the source multi-select to influence the target multiselect?
What happens when multiple items are selected? Does the target multi-select simply offer a combination of choices mapped to each source option?
If so, this should roughly work:
def formFieldA = getFieldByName('fieldA')
def formFieldB = getFieldByName('fieldB')
def map = [
'A':['Monday', 'Wednesday'],
'AB':['Monday', 'Tuesday']
]
def cfFieldB = customFieldManager.getCustomFieldObject(formFieldB.fieldId)
def config = cfFieldB.getRelevantConfig(issueContext)
def allOptions = optionsManager.getOptions(config)
def optionsToAllow = allOptions.findAll{ option->
(formFieldA.value as List).any{map[it].contains(option.value)}
}
formFieldB.setFieldOptions(optionsToAllow)
Othe types of interactions/algorithm will require more specific example.
Hi @Peter-Dave Sheehan :
Thanks a lot for the solution. It worked fine. I was also doing it as a test case before i go for actual requirement If you can help in my actual requirement it would be very helpful to me.
I have two fields
Affected version for clients - (Multiversion picker) 2.3, 2.4,2.5
Other affected Clients - (Multiselect field) A, B, C, D
2.3 is related to A & B
2.4 is related to C
If i select 2.3, 2.4 is version, the Other affected Clients should automatically map to A, B, C.
I wrote this code from your solution provided. But its not taking the values. Can you please help
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def versionManager = ComponentAccessor.getVersionManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def formFieldA = getFieldById(fieldChanged)
def formfieldAValue = versionManager.getVersion(issueContext.projectObject.id).getId() as List
def formFieldB = getFieldByName('Other affected clients')
def map = ['2.3':['A','B'],'2.4':['C'],'2.5':['D']]
def cfFieldB = customFieldManager.getCustomFieldObject(formFieldB.fieldId)
def config = cfFieldB.getRelevantConfig(issueContext)
def allOptions = optionsManager.getOptions(config)
def optionsToAllow = allOptions.findAll{ option->
(formfieldAValue).any{map[it].toString().contains(option.value)}
}
formFieldB.setFormValue(optionsToAllow*.OptionId)
log.warn("test"+optionsToAllow)
Regards,
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, it looks like you are getting a formfield object: formFieldA, and then you don't use that anywhere.
How did you think you were getting the selected values?
You can add a line of code like this to give you some clues as to what happens when you select a version:
formFieldA.setHelpText("$formFieldA.value (${formFieldA.value[0].getClass()})")
What I saw in my environment was "VersionImpl".
So I renamed some variables and adjusted the code to take that into consideration
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.version.VersionImpl
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def versionManager = ComponentAccessor.getVersionManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def formFieldA = getFieldById(fieldChanged)
def selectedVersions = formFieldA.value as List<VersionImpl>
def formFieldB = getFieldByName('Other affected clients')
def map = [
'2.3': ['A', 'B'],
'2.4': ['C'],
'2.5': ['D']
]
def cfFieldB = customFieldManager.getCustomFieldObject(formFieldB.fieldId)
def config = cfFieldB.getRelevantConfig(issueContext)
def allOptions = optionsManager.getOptions(config)
def optionsToSet = allOptions.findAll { option ->
(selectedVersions).any { selectedVersion -> map[selectedVersion.name].contains(option.value) }
}
formFieldB.setFormValue(optionsToSet*.optionId)
log.warn("test" + optionsToSet)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, it solved all issue and things you pointed out really helps me in future.
Regards,
Ankit
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.