How to hide/show Message custom field (for edit) based on checkbox?

Teja July 13, 2017

Hi,

I have added custom message field on the transition screen and I would like to make that message field popup and popoff based on the checkbox selection.

Ready.PNG

The checkbox name is 'Common Component Change Request' and value 'Not Requested' if user didnot check this box then only I want to show this message else not.

How to do that?

2 answers

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.
July 14, 2017

You can try to inject your own javascript, but you would be better off with an add-on that does it internally (as injection is difficult, ugly and often fails)

Script Runner has the Behaviours module which pretty much had show/hide other field as it's first reason to exist.  There are others, including Dynamic Forms as Daniel mentions which can enable it

Teja July 14, 2017

Hi Nic,

I tried injecting my javascript in field configuration and even in custom field's edit default values but it didnt work.

My code will be like this:

//Common Component cf_14503

//Message field cf _4300

$('#customfield_14503-2').click(function () { 

 

if (document.getElementById('customfield_14503-2').checked) {
AJS.$("#customfield_14300").closest('div.field-group').hide();

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

}}

I dont no much information on javascript and where would you suggest to apply this code to affect.

 

Thanks

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.
July 14, 2017

Atlassian have been removing the abilty to inject dubious javascript like that.  The only place it works now is in the announcement banner.

Teja July 14, 2017

Hi Nic,

I tried it in the announcement banner but didnt work for me either.

Thanks

 

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.
July 14, 2017

Is the javascript injected ok, and just not appearing to run?  Use the debug tools in the browser to find it.

Teja July 14, 2017

It works for other custom fields but not for message field.

Let me find it in the debug tools.

Thanks

0 votes
Daniel Bajrak
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.
July 14, 2017

Hi,

have you tried to use add-on Dynamic Forms? There are several custom fields that can show and hide other custom field depending on selected value. I think that dynamic check box is what you are looking for.

 

I hope I've helped you.

 

Best Regards

Teja July 14, 2017

Hi Deniel,

I really appreciate you response.

Actually we are using that message field only one place. Does it seems expensive to buy add-on for less usage.

What would you say?

Thanks

Suggest an answer

Log in or Sign up to answer