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,295,690
Community Members
 
Community Events
165
Community Groups

Is it possible to populate the approved field (multiple group type) based on the product field value

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)
}Configuration - script2.pngConfiguration - script.png

 

Best regards,

Layssa Souza

1 answer

1 accepted

1 vote
Answer accepted

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("")
}

Hello @Kawan Diogo,

Thank you so much, this worked for me! :)

 

Best regards,

Layssa Souza.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you