Show/Hide fileds based on selection

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 vote

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.


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 Community Champion Sep 12, 2012

Hey Raj ,

Try

If(Priority .equals("Blocker"))

as a condition.

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)

}

}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you