Show/Hide fileds based on selection

Rajeshbabu Ellappan September 12, 2012

Hi, I am new to JIRA and using JIRA4.4.4 with behaviour plugin installed, i want to show/hide fileds based on

user selection in the list field, i have a requirement to show a field based on priority selection, if my priority is a Blocker, i want to show a description field, so i configured behaviour plugin to my project, added the hidden text free field and made it hide and added the below validator.

public void setPriorityJustification() {
FormField priField = getFieldById ("priority")
FormField priJustField = getFieldByName ("Priority Justification")
String priority = (String) priField.getFormValue()
if (priority == "1") { // 1 is Blocker
priJustField.setHidden(false)
}
else {
priJustField.setHidden(true)
}
}
But when i create issue i dont see any changes, any help would be good for me.

1 answer

0 votes
JamieA
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.
September 12, 2012

Is the behaviour mapped to the project? Is that code attached to the priority field (and not to Priority Justification)?

> added the hidden text free field

Not sure what you mean by this - just add a text field. If the priority is not 1 it will be hidden, as the code above will run when the form is first displayed.


Rajeshbabu Ellappan September 12, 2012

yes, i mapped the behaviour to the project, now i removed the hidden text field and added just the text field named Priority Justification, added the validator script to Priority field and below is the script. But nothing happens when click on click create, just the text field is displaced in the default screen and the i am getting the log message as 704x1074x1 bgo9dp 10.14.161.192 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Returning map: [:]

My script as below.

import org.ofbiz.core.entity.GenericValue

import com.atlassian.jira.ComponentManager

public void setPriorityJustification() {

FormField priField = getFieldById ("Priority")

FormField priJustField = getFieldByName ("Priority Justification")

String Priority = (String) priField.getFormValue()

if (Priority == "1") { // 1 is Blocker

priJustField.setHidden(false)

}

else {

priJustField.setHidden(true)

}

}

Should i add any additional plugin ?? Pls help...

Mizan
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.
September 12, 2012

Hey Raj ,

Try

If(Priority .equals("Blocker"))

as a condition.

Rajeshbabu Ellappan September 12, 2012

Tried as below, Still the same effect by default the text field should not appear, but when i click on create issue, the text filed appears as it is and when i select blocker and other priorities also there is no effect. any solutions pls.

import org.ofbiz.core.entity.GenericValue

import com.atlassian.jira.ComponentManager

public void setJustification() {

FormField priField = getFieldById ("Priority")

FormField priJustField = getFieldByName ("Justification")

String Priority = (String) priField.getFormValue()

if (Priority.equals("Blocker")) { // 1 is Blocker

priJustField.setHidden(false)

}

else {

priJustField.setHidden(true)

}

}

Rajeshbabu Ellappan October 10, 2012

Got Resolved.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events