Forums

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

Script Runner Behaviours problem

Sahish November 16, 2021

Hi People,

We have two fields Defect Classification and Function Classification in one screen,

So if I select "Hardware Error" as my Defect Classification, the custom field Function Classification should not appear on the screen. I have implemented this in behaviours with below script. But I am not getting the correct output, even if I choose "Hardware error" still I can see Function Classification. May I know why I am not getting correct output.

The script follows:

import static com.atlassian.jira.issue.IssueFieldConstants.*

import com.atlassian.jira.component.ComponentAccessor;

import com.onresolve.jira.groovy.user.FieldBehaviours

import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours

   

    def defectclassification = getFieldById("customfield_15663")

    def functionclassification = getFieldById("customfield_16663")

 

    if (defectclassification == "Hardware Error") {

        functionclassification.setHidden(true)

    }

1 answer

0 votes
Juan José Marchal Gómez
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.
November 16, 2021

Hello @Sahish 

could you try with 

 

getFieldByName("customfield_15663").getValue())

 

instead of getFieldById("customfield_15663")

 

also, I've recommend to set as String instead of def.

 

Best regards.

Sahish November 16, 2021

Thanks for your response @Juan José Marchal Gómez . But I am getting the required output even after modification of the code with your changes.

Suggest an answer

Log in or Sign up to answer