Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Show value in select list as per the previous value selected in dropdown field.

Vikrant Yadav
Community Champion
May 21, 2020

Hi 

I have one query, i have 2 dropdown field. Client and ClientCode. 

In Client field if someone select USA then Clientcode will automatically set to NAMR. 

If in client field someone select UK then Clientcode will automatically set to EMEA. 

 

Please suggest how can i do this, i have script runner plugin. Both are dropdown field, do i need to create one scripted field for this ? Please suggest 

 

@Stephen_Wright  @Nic_Brough__Adaptavist_  @Kristian Walker (Adaptavist) @Adrian_Stephen @Derek_Fields @Ravi_Sagar__Adaptavist_ @Martin Bayer [MoroSystems, s.r.o.] 

 

Thanks

2 answers

1 accepted

0 votes
Answer accepted
František Špaček _MoroSystems_
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.
May 21, 2020

Hello,

the need of scripted field depends on usability of the field. If you want to leave ClientCode as text field which can user eventually change to his own value, you need Behaviours and classic text custom field. If you need field to be non editable and value always depends on Client field, then scripted field is probably good choice.

Vikrant Yadav
Community Champion
May 21, 2020

Hi @František Špaček _MoroSystems_  can you please help me with the script, i am new to JIRA and script runner. 

 

Thanks 

František Špaček _MoroSystems_
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.
May 21, 2020

And which of these two options are needed? Do you need editable field or does the field depends on other field all the time?

Vikrant Yadav
Community Champion
May 21, 2020

Hi @František Špaček _MoroSystems_   i don't want editable field, just read only. 

Thanks

Vikrant Yadav

František Špaček _MoroSystems_
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.
May 27, 2020

Hello Vikrant,

 

the bets option would be go for scripted field then.

In ScriptRunner administration go to Fields and create new field here (it will automatically create new on in Jira configuration too). Put there a name you want, as a template select Text (multiline).

In script, try something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

final def CLIENT_CF = "customfield_11201"

CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class)
CustomField clientCF = customFieldManager.getCustomFieldObject(CLIENT_CF)

def client = issue.getCustomFieldValue(clientCF)

def returnVal = ""

switch (client){
case 'UK': returnVal = "EMEA"; break;
case 'USA': returnVal = "NAMR"; break;
}

return returnVal

 

You only have to change id of CF at the script start, you can also easily add another options in switch statement if needed.

Like Vikrant Yadav likes this
Vikrant Yadav
Community Champion
May 27, 2020

Hi @František Špaček _MoroSystems_  Thanks for the solution. 

0 votes
Vikrant Yadav
Community Champion
May 22, 2020

Hi @Alexey Matveev  can you please suggest on this.

 

Thanks

Suggest an answer

Log in or Sign up to answer