Forums

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

How do you make a field mandatory in the Edit screen, depending on the selection of a Component

Karl Samson
Contributor
July 26, 2023

I want to make certain fields mandatory in the Edit screen, but only when a certain Component is selected in the issue.

I've tried using ScriptRunner to do this, but can't seem to write the right server script to check for the correct Component selection?

So for example, if 'M&P' is selected, I want the fields to show as mandatory. If 'Design' is chosen, then NOT Mandatory.

Ideally, I only want certain fields displayed and mandatory when the 'M&P' component is selected, but hidden otherwise. 

1 answer

0 votes
Nic Brough -Adaptavist-
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 26, 2023
Karl Samson
Contributor
July 26, 2023

Thanks Nic, I'll try to adapt the script to use 'Component'.

Karl Samson
Contributor
July 31, 2023

Ok. So I've come up with the below, but it doesn't work:-

 

import com.atlassian.jira.bc.project.component.ProjectComponent

def formComponent = getFieldByName("Component")
def ActionQNField = getFieldByName("Action QN")

if (((formComponent) formComponent.Value).name in["M&P"]) {
    ActionQNField.setRequired(true) }    

Suggest an answer

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

Atlassian Community Events