Forums

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

Hiding field based on picked group in group picker

Christian Körner April 17, 2018

In a "Create Issue" screen I am trying to hide a custom field based on a value of a group picker field. The field should be hidden for all groups apart from a particular group.

I am using the Scriptrunner Behavior plugin.


// Group ID is the group picker field
FormField fieldFF = getFieldByName("Group ID");
String fieldValue = fieldFF.getValue();
if(!"Some Special Group".equals(fieldValue)){
FormField fieldToHideFF = getFieldByName("Initial Severity");
fieldToHideFF.setHidden(true);
}


However when adding both fields to the behavior this does not work. I am setting the group picker field via a http GET parameter.

 

Thanks in advance!

 

Edit: Added problem statement

1 answer

0 votes
Alexey Matveev
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.
April 17, 2018

And what is the problem? You should add the Group Id field to your behaviour and add this script for the field. Do you have any errors?

Christian Körner April 17, 2018

Sorry, I updated the question. Even when adding both fields to the behavior the field is not displayed when the group picker is set to "Some Special Group".

Alexey Matveev
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.
April 17, 2018

Behaviours do not work with http calls

Christian Körner April 17, 2018

I know. I merely use the http call to fill the value of a group picker field. Based on the filled in value I need to hide or show a certain other field.

Alexey Matveev
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.
April 17, 2018

Could you add logging to your script and have a look in the logs?

FormField fieldFF = getFieldByName("Group ID");
log.error("fieldFF: " + fieldFF)
String fieldValue = fieldFF.getValue();
log.error("fieldFF value: " + fieldValue)
if(!"Some Special Group".equals(fieldValue)){
log.error("in condition")
FormField fieldToHideFF = getFieldByName("Initial Severity");
log.error("fieldToHideFF: " + fieldToHideFF)
fieldToHideFF.setHidden(true);
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events