I am working using Forms for Confluence to create Jira issues and have had good success using the https://www.adaptavist.com/doco/display/F4C/Creating+an+Issue+in+Jira+by+Submitting+a+Form+in+Confluence
Does anyone have any examples of how to do this?
Thanks for the help
Diane
From you description, I understand that you want to use the Behaviour to add new values / options in the Multi-Select Field. Is this correct?
If yes, then this is not doable. If you are using the standard Multi-Select field, you can only filter the options that are provided using the Behaviour as shown in this sample code from the Adaptavist Library. You will not be able to use the Behaviour to add new options to it.
I am looking forward to your clarification.
Thank you and Kind regards,
Ram
Hey Ram,
This wouldn't be adding new values. The purpose is to filter down values from a large list, based on what was selected in a multi-select field.
The sticking point is that I would ideally have it cycle through if multiple matches to the values on the multi-select field were selected.
For example, say I have a field called "MS 1", a multi-select field. It has values of: [Foo, Bar, Lorem, Ipsum]
And we have another field, let's call that "MS 2" which is another multi-select with values of: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to use a behavior to grab all the fields in "MS 1" whenever there is a match in the map, then compile a list of applicable values from "MS 2", so that only relevant values are shown.
For example, say that if we were to check the context of "MS 1" and it included [Foo, Ipsum] I would look up the contexts for the values: Foo and Ipsum.
Foo values are [1, 3, 5]
Ipsum values are [2, 4, 6]
The total values that should present are: [1, 2, 3, 4, 5, 6] because of the values returned from Foo + Ipsum.
I have this working as a single match, but I'm having difficulties getting it to match and add the additional values. As a single match it looks like:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
@BaseScript FieldBehaviours fieldBehaviours
def im = ComponentAccessor.issueManager
def cfManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
// Value to Project ID Map
HashMap<String, Integer> contextMap = new HashMap<String, Integer>();
// str is group value, int is mapped project ID
contextMap.put('ADEMO', 16601);
contextMap.put('AWOLBP', 16901);
contextMap.put('Other Option', 16309);
contextMap.put('Another Option', 18402);
contextMap.put('More Options',16601);
contextMap.put('Yeehaw', 16800);
// Field Configuration Area
def teamDisciplines = getFieldById("customfield_25124")
def teamDisciplinesObjects = cfManager.customFieldObjects.findByName("Team(s)")
log.warn("ProductTeam Objects: $teamDisciplinesObjects")
def productLines = getFieldById("customfield_25123")
def productLinesObjects = cfManager.customFieldObjects.findByName("Product Line(s)")
log.warn("ProductTeam Objects: $productLinesObjects")
// Group Field Configuration IE "MS 1"
//def productGroup = customFieldManager.getCustomFieldObject(19703)
def productGroup = getFieldById("customfield_25810")
def groupValueList = productGroup.value as List
def groupValue = productGroup.getValue() as String
// def groupValue = issue.getCustomFieldValue(productGroup) as String
log.warn "Custom field value type or class" + groupValue.getClass()
log.warn "Group Value: $groupValue"
def cleanGroupValue = groupValue.replaceAll("\\[|\\]","")
log.warn "$cleanGroupValue"
// If value is null
if (groupValueList == [null] || groupValueList.contains("Assign for Triage")) {
productGroup.setError("Please select a valid Group for more options")
productGroup.setRequired(true)
teamDisciplines.setReadOnly(true)
productLines.setReadOnly(true)
return "Null group value or Needs Triage."
// If more than 1 value is selected
} else if ( groupValueList.size() > 1 ) {
productGroup.setError("Please only select one option.")
teamDisciplines.setReadOnly(true)
productLines.setReadOnly(true)
}
log.warn("Getting the $cleanGroupValue:" + contextMap.get(cleanGroupValue))
def contextId = contextMap.get(cleanGroupValue)
if (groupValueList != [null]){
teamDisciplines.setReadOnly(false)
productLines.setReadOnly(false)
productGroup.clearHelpText()
def getApplicableContext = new IssueContextImpl(contextId,null)
// Team Disciplines i.e "MS 2"
def getTeamDisciplineConfig = teamDisciplinesObjects.getRelevantConfig(getApplicableContext)
List teamDisciplinesValueList = optionsManager.getOptions(getTeamDisciplineConfig)
log.warn "Using Team Discipline(s) values: $teamDisciplinesValueList"
def teamDisciplinesOptionsList = []
teamDisciplinesValueList.each {
teamDisciplinesOptionsList.add(it.toString())
}
teamDisciplines.setFieldOptions(teamDisciplinesOptionsList)
log.warn "Team Discipline Values filtered to $teamDisciplinesOptionsList"
} else {
productGroup.setHelpText("Please select a Group to proceed.")
teamDisciplines.setReadOnly(true)
productLines.setReadOnly(true)
}
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.