How to make a hidden customfield dependent on another customfield?

Bharadwaj Jannu
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.
August 21, 2013

Hi,

I have two customfields of same type and same options, but one of them is hidden in all screens.

Now if a non-hidden customfield's option is selected, the hidden field should also be set with its respective option.

Thanks,

Bharadwaj Jannu

5 answers

1 accepted

0 votes
Answer accepted
Bharadwaj Jannu
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 2, 2013

I got the solution by creating a new customfieldtype which extends MultiSelectCFType(required for our customfield).

In that I overrode getVelocityParameters method with the required things.

0 votes
Chaithra N
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.
August 22, 2013

Use the Copy Value From Other Field Post function which is part of JIRA Suites

Bharadwaj Jannu
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.
August 22, 2013

Hi Chaitra, thanks for the reply

But using workflow postfunction, the functionality will not work for edit operation?

Chaithra N
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.
August 22, 2013

Dont have the Edit Operation. (this can be controlled by permission)

In Your Workflow have Edit tranistion at all the status & at this tranistion use the post function & this should work.

Bharadwaj Jannu
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.
August 22, 2013

I didn't get you exactly.

My thinking is that though we write or use a workflow postfunction, it is going to work on creating or transitioning a issue only and it is not going to work on editing an issue. If not, please correct me.

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.
August 22, 2013

You are correct - you can't do post-functions on Edit.

This is why Chaithra said "don't have the edit operation". You remove the edit permission from the project, and create transitions in the workflow called "edit" which go back to the current status.

Chaithra N
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.
August 25, 2013

You can only have post function at Workflow transtion & not on the updates of customfield.

Other options are,

  1. Use JAVA Scripts for copying the contents of the customfield.
  2. Have a servlet & in the Servelt copy the contents, call on the servlet must happen based on the update on the required customfield.
  3. Listners can be used

But I personnally feel Workflow is much easier.

Bharadwaj Jannu
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.
August 25, 2013

Thanks Nic,

I got little idea on this. But rather moving to workflow changes, is there any kind of post functionality executed immediately after the customfield is checked/selected and before the update button is pressed on edit screen?

If at all exists, please help in that concern.

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.
August 25, 2013

I feel like we're repeating ourselves here. We both keep telling you there are no post-functions on Edit. Then you ask the same question again.

Please re-read Chaithra's detailed answers again, mine are just "there are no post-functions on Edit", and Chaithra gives you the options I'd suggest already

Bharadwaj Jannu
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.
August 26, 2013

Hi @Nic @Chaitra

I try to use listener approach.

For issue creation: ISSUE_CREATED

For issue updation: ISSUE_UPDATED event types exist.

Now the ISSUE_UPDATED event is generated for updations using issue panels also.But is there any event specific to issues updating from edit screen itself?

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.
August 27, 2013

Issue updated is the event fired from edit. When you say "generated for updates using issue panels", what's actually happening is the system is using "Edit", but not going through the screen. It's the same process, but with only one field.

0 votes
Sreenivasaraju P
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.
August 22, 2013

You can write a post function to copy field A(available on scree) to field B(hidden).

0 votes
RambanamP
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.
August 21, 2013

if the field are select list then you can try with following code

<script type="text/javascript">  
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		setFieldValue();
	});
		setFieldValue();
function setFieldValue(){	
		setValue();
		//showing field
	$('#customfield_13816').change(function() {
		setValue();
	});
}
function setValue(){
var parentFieldValue=$("#customfield_13816 option:selected").text();
//hidden field
$("#customfield_13817 option").each(function() {
  if($(this).text() == parentFieldValue) {
    $(this).attr('selected', 'selected');            
  }                        
});
}

});
</script>

add above script on second field description in field configuration

Bharadwaj Jannu
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.
August 22, 2013

Hi rambanam,

Thanks for the answer, but using script make the browser compatible problems.

Is there any kind of functionality(like postfunction) which run exactly after a customfield is updated?

or by means of any plugin(like implementing cascade customfields) can we achieve this?

RambanamP
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.
August 22, 2013

another option is by hiding custom field using JavaScript and then you can fill the field valu by using postfunction

0 votes
EddieW
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.
August 21, 2013

If you want the field to change without a workflow transition or client side JS, using Event listeners is the only remaining option I can think of.

https://confluence.atlassian.com/display/JIRA/Listeners

You can configure it to listen for the Issue Updated event and take whatever action you wanrt.

You may not be able to change the value of a hidden field, but if it is possible the JIRA Behaviors Plugin is the way to do it.

https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours

Suggest an answer

Log in or Sign up to answer