Want to display different values in a new text field from the option selected in the Jira Field

Kay January 3, 2020

Hello Community, 

Can someone please advise changing the piece of code below to covert the set option selecting from a field in Jira to a different value and display in a new field separated by comma? I have Field1 with a bunch of options already set in Jira but I have created Field2 as a text that I want to display all options as defined in Def from C1-C22 which equals to each options in Field1. My below code can give the same behavior I want, but I only can display the option from Field1 not from the component the of component IDs below. 

Example: if the list of options in Field1 Jira is 1, 2 &3, when select 1 &2, Field 2 should display Cat, Dog. 

Thank you in advance for your kind help. Looking forward to your answers. 

 

import com.atlassian.jira.component.ComponentAccessor
import groovy.transform.BaseScript
import com.atlassian.jira.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.core.util.StringUtils

@BaseScript FieldBehaviours fieldBehaviours

 

def optionsManager = ComponentAccessor.getOptionsManager()// Get the Custom Field Manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// Get a pointer to my select list custom fields
def selectList1 = getFieldByName("Field1")
def selectList2 = getFieldByName("Field2")


// Set List of Component IDs
def C1 = "Cat"
def C2 = "Dog"
def C3 = "Rat"


def selectList1Val = selectList1.getValue()

if (selectList1 != null)
{
selectList2.setFormValue(selectList1.getValue())
selectList2.setReadOnly(true)
}
//All other selections
else
{

selectList2.setReadOnly(false)
selectList2.setHidden(false)
}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events