Forums

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

Change field based on another field

Antonio Caeiro October 11, 2022

Hi,

 

I have two fields:

1. Incident Severity (dropdown list)

2. SLA SEV (number field)

 

On a workflow transition, i need field 2, to change to a specific number, depending on the field 1 value. On the transition, i will change the field 1 value.

Field 1, have 5 entries.

 

ex. If field 1 = "SEV 3", then field 2 = "5", if field 1 = "SEV 4", the field 2 = "7";
and so on up to 5 options

 

tks

Antonio

3 answers

1 accepted

0 votes
Answer accepted
Burak Bal October 12, 2022

Hi Antonio,

I understand what you mean now. You want to auto fill the fields.

You can use Scriptrunner Behaviours. Create an new behaviour and Add the "Field 1".  Then, use the Add server-side script button to add code below.

I hope this helps you. 

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

def Field_1= getFieldByName('Field 1')
def Field_2 = getFieldByName('Field 2')


if( getFieldById(getFieldChanged()) == Field_1)
{
switch(Field_1.value) {
case "5": Field_2.setFormValue("10"); break;
case "4": Field_2.setFormValue("5"); break;

}
}
Antonio Caeiro October 12, 2022

that is perfect. tks

Burak Bal October 12, 2022

Glad to hear that. You are welcome.

0 votes
Zeeshan Ahmed Khan
Contributor
February 5, 2023

Hi @Burak Bal

Is this solutoin applicable to Jira Service Management (Cloud) product as well ? I have got the scriptrunner and also the behavior add-on but the the above solution doesnt seem to be working for me unfortunately !

Kate Pawlak _Appsvio_
Community Champion
February 6, 2023

Hi @Zeeshan Ahmed Khan ,

If you need such a solution for the customer portal, use Forms. With this native feature, you can build forms with conditions, so you can display a different set of fields depending on the selection in the previous field.

Best regards,

Kate

Chief Product Officer & Co-founder @Appsvio | Atlassian Community Leader

Zeeshan Ahmed Khan
Contributor
February 6, 2023

Hi @Kate Pawlak _Appsvio_ 

I have added the app "Dyanmic Forms for Jira" and tried creating a form having fields linked to Jira native fields. Refer screenshot below. What I want is to make a custom text field visible (where the black arrow is) only if the user select 'Other' in the "Affected Service" field. Is this possible with this app or do I need any other additional plugin ?

 

image.png

Kate Pawlak _Appsvio_
Community Champion
February 7, 2023

Hi @Zeeshan Ahmed Khan ,

This app you mentioned works only for Jira issues on Create issue screen.

You don't have to install any additional apps.

As I understand, you want to create a dynamic form on the customer portal which means Jira Service Management. You have to go under project settings and select Forms. There you have to configure sections and based on these sections define which should be visible when someone selects the XYZ option in the ABC field. Here you can find fantastic documentation from Atlassian: click

Let me know if it helps.

Kate

Zeeshan Ahmed Khan
Contributor
February 7, 2023

Thanks heaps @Kate Pawlak _Appsvio_ , that worked !

Like Kate Pawlak _Appsvio_ likes this
0 votes
Burak Bal October 11, 2022

Hi Antonio,

Please check this existing entry. You can do it with Scriptrunner Behaviours. You can't hide the option, but you can set option that you want to be visible.

Or, you can create new fields as much as count of Field 1 options. So, you can customize the options of new field. Then, you can hide or show the related field. You can do it with Behaviours again. Check here.

Antonio Caeiro October 12, 2022

Hi Burak,

 

tks for the reply. Tha case you sharedm just turns the field visibla (or not) and mandatory.

This is what i need:

Field1 - Dropdown list options (1; 2; 3; 4; 5)

Field2 - Number field

 

When i select field1 option 5, the field2 should be set to 10;

if i select field1 option 4, the field2 should be set to 5;

and so on.

 

tks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.6.1
TAGS
AUG Leaders

Atlassian Community Events