How do I hide custom fileds based other custom field on create screen only?

Teja April 10, 2017

Hi,

I have a checkbox custom field named 'Fruits' and value Requested.

And other 3 more custom fields.

When user clicks Requested it should shows other 3 custom fields else not.

Prior to that all 3 custom fields must be hidden.

 

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 10, 2017

You will need some code to do that.  Either a custom field type that can support it, or injected javascript. 

The Behaviours module in the script runner add-on can do this too, it does the javascript for you.

Teja April 11, 2017

Yes Nic,

I am using this below code using JavaScript through the plugin

function fruitnewField(){

$('#customfield_14201-1').click(function() {   // Fruit cf


if (document.getElementById('customfield_14201-1').checked){ AJS.$("#customfield_14202").closest('div.field-group').show();  //other cf
AJS.$(":input[name='customfield_14203']").closest('fieldset.group').show();  //other cf
AJS.$("#customfield_14204").closest('div.field-group').show();  //other cf

}
else{
AJS.$("#customfield_14202").closest('div.field-group').hide();

AJS.$(":input[name='customfield_14203']").closest('fieldset.group').hide();
AJS.$("#customfield_14204").closest('div.field-group').hide();
}
});

When I checked check box other cf are shows and when I unchecked it cf are hides.

But the problem is how to hide these other custom fields on the load of create screen when the check box is unchecked defaultly.

Suggest an answer

Log in or Sign up to answer