Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

203 views 2 5
Read article

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