Hello guys,
I'm trying to create the following script: When my field of type list is selected the option "AAA" my field of approvers (of the type multiple group) must fill with the group "AAA"
If it is the "BBB" option, you must fill in the "BBB" group and so on.
Is it possible to perform this configuration?
Below I share the script that I am customizing
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cat = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("Produto")
def selectListValue = cat.getClass()
def groupManager = ComponentAccessor.getGroupManager()
def multiGroupCf = customFieldManager.getCustomFieldObjectByName("Aprovadores") //multigroup picker custom field
//def changeAreaFieldObject = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11200")
def TeamDatagroup = groupManager.getGroup("Aprovadores-técnicos-JIRA") //jira group
def BOgroup = groupManager.getGroup("Aprovadores-Linux") //jira group
def groupList = [TeamDatagroup]
if (cat in selectListValue == "Jira Software") {
issue.setCustomFieldValue(multiGroupCf, groupList)
}
Best regards,
Layssa Souza
Look, through the post function I couldn't reproduce the commented effect, but you can use Behaviors to assign a fixed value in the "Aprovadores" field.
It would be something like:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final singleSelectName = 'Produto'
final textFieldName = 'Aprovadores'
def singleSelect = getFieldByName(singleSelectName)
def singleSelectValue = singleSelect.value
def textField = getFieldByName(textFieldName)
//Set the appropriate value, dependent on the value of the currently selected single select option
switch (singleSelectValue) {
//Change 'Single Select Option...' to match your single select's values.
case 'Value A':
textField.setFormValue('Aprovadores-técnicos-JIRA')
textField.setReadOnly(true)
break
case 'Value B':
textField.setFormValue('Aprovadores-Linux')
textField.setReadOnly(true)
break
//Reset to default value if single select option is null or any other option that is not taken care of
default:
textField.setFormValue("")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.