Hide a field based on a multiselect value from previous screen?

Hi, 

I have a field called "Cust care team" of type Select list single choice. 
I want it to appear only if on previous screen, a field called "Department and Team" of type select list cascading contains value "Customer care" (1st dropdown) or "Customer Care - Customer Service" (1st and 2nd dropdown) 

I know a cascading select list returns an index, but I'm having trouble getting it to work. 
Using JIRA Behaviours, as a serverside script. 

I previously had this: 

import com.atlassian.jira.component.ComponentAccessor

def dept = getFieldByName("Department and Team") //Multi Select Field
def custcare = getFieldByName("Cust Care Team")


def deptValue = dept.getValue(); //Getting Value of Multi Select Field

if(dept.toString().contains("Customer Care - Customer Service"))
{
custcare.setHidden(false)
}else{
custcare.setHidden(true)
}

I also tried an initialiser:
cfValues['Department and Team']?.values()*.value[0].contains("Customer") 

Thank you 

 

2 answers

1 accepted

This widget could not be displayed.
Mahesh S Community Champion Nov 29, 2016

You can achieve it easily using javascript. Please tell me whether you use both fields in the same screen or diff screens? If different, what kinda screen they are (like transition screen or ..?)

A screenshot might help.

Mahesh S Community Champion Nov 30, 2016

Here we go!!

  1. Add this javascript into the description of "Cust care team" in the field configuration. 
  2. Replace "customfield_10405" by the customfield id of your "Department and Team" field.
  3. Replace "customfield_10406" by the customfield id of your "Cust care team" field.
  4. Replace "10303" by the valueId of "Customer Care" option in first drop down.
  5. Replace "customfield_10405:1" by the customfield id of your second cascade dropdown.
  6. Replace "10305" by the valueId of "Customer Service" option in second drop down.

 

<script>
if(document.getElementById("edit-issue-dialog").className == "jira-dialog box-shadow jira-dialog-open popup-width-custom jira-dialog-content-ready")
{
	var x=document.getElementById("customfield_10406");
        x=x.parentNode;
	x.style = "display: none;";
	document.getElementById("customfield_10405").addEventListener('click',function ()
	{
	 if((document.getElementById("customfield_10405").value == "10303") && (document.getElementById("customfield_10405:1").value == "10305"))
	{
		x.style = "display: block;";
	}else{
		x.style = "display: none;";
		document.getElementById("customfield_10406").value = ""
	}
	}  ); 

	document.getElementById("customfield_10405:1").addEventListener('click',function ()
	{
	 if((document.getElementById("customfield_10405").value == "10303") && (document.getElementById("customfield_10405:1").value == "10305"))
	{
		x.style = "display: block;";
	}else{
		x.style = "display: none;";
		document.getElementById("customfield_10406").value = ""
	}
	}  ); 
}
</script>

It works for me!!

While choosing Customer Care- Customer Service

image2016-11-30 20:42:56.png

While choosing a different option.

image2016-11-30 20:42:14.png

Get the fieldId and valueIds from Inspect element of chrome browser easily OR via browser URL in field configuration while adding options for the "Department and Team" field. Lemme know if u face any difficulty.

 

Cheers!

Mahesh

This widget could not be displayed.

Hi,
Thank you. First field ("Department and Team") is on create screen.
Second field "Cust care team" is in ticket, when user clicks a button, so it's a transition screen.

Let me know if that's enough or if you need the screenshots

Thanks

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

292 views 5 0
Join discussion

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