Forums

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

Display a CustomField when a specific resolution is selected-jira server

Priti Sonar January 12, 2022

I have writeen a code for the requirement -I would like to display CustomField only when i pick a specific resolution value.

Code:
import static com.atlassian.jira.issue.IssueFieldConstants.RESOLUTION
def resolutionField = getFieldById(RESOLUTION)
def TestField = getFieldById("customfield_30200")
if (resolutionField.getValue().toString().equals('Fixed'))
TestField.setHidden(false)
} else

{ TestField.setHidden(true) }

But it The field is not getting affected by any value change while transition .
It is always going directly to else loop not taking the selected value from resolution field .
Please have a look into it .

1 answer

0 votes
Tansu Akdeniz
Community Champion
January 12, 2022

Hi @Priti Sonar 

Try this one:

import com.atlassian.jira.issue.resolution.Resolution

def resolutionField = getFieldById("resolution")
def TestField = getFieldById("customfield_30200")

def resolution = resolutionField.getValue() as Resolution

if (resolution.name.equals('Fixed')){
TestField.setHidden(false)
} else{ 
TestField.setHidden(true) 
}

There is a sample in this link

You can also temporarily use .setHelpText() to see the variable in the screen.

Ex: resolutionField.setHelpText(resolution) etc.

Priti Sonar January 12, 2022

Hi @Tansu Akdeniz ,

Tried your code , unfortunately still the same situation .

Here fixed is the Default value of Resolution field 

TestField is visible (nevertheless which value is being selected in the resolution dropdown)

I m using behavior to fulfill this requirement  and written the code  like this :

hsm.PNG

have a look to the screenshot .

I m not sure if i m doing somewhere wrong should i need to put the code in initializer section or something else

Suggest an answer

Log in or Sign up to answer