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

suchitk July 13, 2016

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
Answer accepted
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2016

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.

suchitk July 27, 2016

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.

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2016

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?

suchitk July 27, 2016

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

 

 

 

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2016

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"])
suchitk July 28, 2016

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

Thank you so much for your help.

0 votes
suchitk July 27, 2016

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.

 

0 votes
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2016

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?

0 votes
suchitk July 22, 2016

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 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2016

What have you tried so far?

Suggest an answer

Log in or Sign up to answer