Populating Text field value in Select list custom field on issue creation

Hello,

I have two custom field named as Epic-QC(Single line text field) and Detailed functionality list(Select list custom field).

I need to populate Epic-QC(Single line text field) to Detailed functionality list(Select list custom field).

So please can you help us on this.

Thanks.

 

5 answers

1 accepted

3 votes

You can do this with the following behaviours script attached to the "Epic-QC" field:

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def epicField = getFieldById(getFieldChanged())

def detailedListField = getFieldByName("Detailed Functionality List")

def epicValue = epicField.getValue()

if (epicValue) {
    detailedListField.setFieldOptions([(epicValue): epicValue])
} else {
    detailedListField.setFieldOptions(["-1": "None"])
}

It will set whatever value is in the "Epic-QC" field into the "Detailed Functionality List" field. If no value is set the value in the list will be None.

Dear @Adam Markham [Adaptavist],

Thank you so much for your response.

I tried your above behaviours script and it is populating "Epic-QC" field value into "Detailed functionality list" but when i click on update i got the error .Please refer the below attachment for the same.

Also When "Epic-QC" field value get populate into "Detailed functionality list" then it should not remove the previous drop-down option values.

epic_qc_to_dfl.jpg

 

Thanks and Regards,

Suchit R Kharatmol.

Those numbers next to the values are the option ids, you need to match it with the corresponding one, So for suchit your code needs to be:

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
 
@BaseScript FieldBehaviours fieldBehaviours
 
def epicField = getFieldById(getFieldChanged())
 
def detailedListField = getFieldByName("Detailed Functionality List")
 
def epicValue = epicField.getValue()
 
if (epicValue) {
    detailedListField.setFieldOptions(["11400": epicValue])
} else {
    detailedListField.setFieldOptions(["-1": "None"])
}

I did not see error myself when testing this. Have you another behaviour enabled for this field or another validator?

Dear @Adam Markham [Adaptavist],

Thank you so much for your response.

I tried your above behaviours script and it is populating "Epic-QC" field value into "Detailed functionality list". Its working fine now without any errors.

Thanks a lot for your help Adam.

Thanks and Regards,

Suchit R Kharatmol

 

 

 

Great, glad you got it working. If you want the other options you need to specify them like so in the setFieldOptions call.

detailedListField.setFieldOptions(["11400": epicValue, "11313": "demo"])

Yes I tried the same and it is working fine  for all other options as well.

Thank you so much for your help.

0 vote

What have you tried so far?

Hi @Jamie Echlin [Adaptavist],

Thank for your response.

I tried the below behavior script.

 

FormField epic=getFieldByName("Epic-QC");
String epic_value=epic.getValue();
log.error("----------- Epic-QC value is---"+epic_value)
FormField dfl=getFieldByName("Detailed Functionality List").setFormValue(epic_value);

Thanks and Regards,

Suchit R Kharatmol.

 

 

 

 

0 vote

Is this a single select list? Do you want to populate the list with values in "Epic-QC" or select one in the list based on "Epic-QC" value?

Hi @Adam Markham [Adaptavist] ,

Thank for your response.

Yes Detailed functionality list is the single list select list custom field. I want  to populate "Epic-QC" value in the Detailed functionality list single list field .

Thanks and Regards,

Suchit R Kharatmol.

 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,304 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot