How to hide 5 fields based on issue type when creating ticket?

Yousuf Al Rawahi
Contributor
April 22, 2024

I want to hide 5 fields based on the issue type when creating a ticket. If I select Epic issue type, all 5 fields will be visible, but if I select other issue types (story, bug, and task), all 5 fields will be hidden. I have used a scriptrunner (Behaviour), but it seems there something missing/wrong. What could be the problem?

 

The 5 fields: Staff ID, Last Day in the Office, VF departments, Staff Name, Line Manager.

 

The script I have used:

 

const staffidField = getFieldById("customfield_11642");
const lastdayintheofficeField = getFieldById("customfield_11637");
const vfdepartmentsField = getFieldById("customfield_11605");
const linemanagerField = getFieldById("customfield_11641");
const staffnameField = getFieldById("customfield_11638");
const issuetypeField = getFieldById("issuetype");

if(issuetypeField.getValue().value == 'Story'){
   staffidField.setVisible(false);
   lastdayintheofficeField.setVisible(false);
   vfdepartmentsField.setVisible(false);
   linemanagerField.setVisible(false);
   staffnameField.setVisible(false);
}
else if(issuetypeField.getValue().value == 'Bug'){
   staffidField.setVisible(false);
   lastdayintheofficeField.setVisible(false);
   vfdepartmentsField.setVisible(false);
   linemanagerField.setVisible(false);
   staffnameField.setVisible(false);
}
else if(issuetypeField.getValue().value == 'Task'){
   staffidField.setVisible(false);
   lastdayintheofficeField.setVisible(false);
   vfdepartmentsField.setVisible(false);
   linemanagerField.setVisible(false);
   staffnameField.setVisible(false);
}
else {
   staffidField.setVisible(true);
   lastdayintheofficeField.setVisible(true);
   vfdepartmentsField.setVisible(true);
   linemanagerField.setVisible(true);
   staffnameField.setVisible(true);
}

1 answer

1 accepted

0 votes
Answer accepted
Stephen_Lugton
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 23, 2024

@Yousuf Al Rawahi you can use screens to define what appears on different issue types and for actions like creating or editing.

Take a look at Defining a screen 

Yousuf Al Rawahi
Contributor
April 23, 2024

I think I have the solution, I have changed from

if(issuetypeField.getValue().value == 'Story'){

to

if(issuetypeField.getValue().name == 'Story'){

 

Thanks.

Like Stephen_Lugton likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events