Forums

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

How Do I Use Multi Cascading Fields To Display A Text Box

Ryan Zore
Contributor
December 14, 2018

I want our Product Bug Issue Type to have a required checkbox asking if the proposed change will have x impact.   

If yes, I want the field to display a multi line text box field requesting more information.  

 

Can anyone point me to documentation that can help me out? 

 

Thanks

Ryan 

3 answers

0 votes
Varun Nelluri May 10, 2020

@Nic Brough -Adaptavist- , Could you please help me how to setup a dynamic fields display based on the Cascading Field list.

I have one Cascading field, Two Text fields on our instance. We want to display or hide text field based on the cascading value.

If possible please provide the script here, Thanks. 

Nic Brough -Adaptavist-
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.
May 10, 2020

There's a load in the library.  https://library.adaptavist.com/entity/set-available-options-to-a-multi-select-list might be a good start

Varun Nelluri May 10, 2020

@Nic Brough -Adaptavist- , I couldn't find the code to display or hide fields based on custom field cascading values.

 

I don't now how to use the logic on the cascading field. Thanks

Nic Brough -Adaptavist-
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.
May 10, 2020

I'd have a look at the rest of the library.  I am not going to write your code for you (I've not done it before so I have nothing to hand over)

Varun Nelluri May 12, 2020

@Ravi Sagar _Sparxsys_ , 

Could you please help me how to setup a dynamic fields display based on the Cascading Field list.

I have one Cascading field, Two Text fields on our instance. We want to display or hide text field based on the cascading value.

If possible please provide the script here, Thanks. 

Ravi Sagar _Sparxsys_
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.
May 12, 2020

Hi @Varun Nelluri 

Can you elaborate your use case a bit in detail? Have you written some code already?

If you are dealing with cascading select list then something like this can be helpful. The code will hide a field based on values selected in cascading select list (parent or child).

/**
Hide a field based on the values selected in either parent or child of a cascading select list.

Cascading field: Country and city
Parent options: [India, UK]
Child options: [Delhi, Mumbai], [London, Reading, Slough]

**/
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.customfields.option.Options

log.debug("******Logging starts********")

def parentField = getFieldById("customfield_10401")
def parentFieldValue = parentField.getValue()
def childField = getFieldById("customfield_10401:1")
def childFieldValue = childField.getValue()
def fieldToHide = getFieldByName("Review Date")

log.debug("Parent Field: " + parentFieldValue)
log.debug("Child Field: " + childFieldValue)

/**Hide based on parent field **/
if( parentFieldValue.containsAll("UK")) {

fieldToHide.setHidden(true)

} else {

fieldToHide.setHidden(false)
}

/**Hide based on child field **/

/*
if( childFieldValue == "Delhi") {

fieldToHide.setHidden(true)

} else {

fieldToHide.setHidden(false)
}
*/

There is no error handling in this code but it will give you some idea.

Ravi

Varun Nelluri May 13, 2020

test

Ravi Sagar _Sparxsys_
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.
May 13, 2020

Method name is containsAll() check your code.

"..if (ProblemCodeValue.fcontainsAll("xxxxx")) { "



Varun Nelluri May 13, 2020

test

Ravi Sagar _Sparxsys_
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.
May 13, 2020

Try to log.debug("ProblemCode Value: " + ProblemCodeValue) to check what it is returning. If it is just a string then in your condition remove containsAll() with ==

Varun Nelluri May 14, 2020

@Ravi Sagar _Sparxsys_ , still not code is not working for me. Do you have any suggestions, Thanks.

Ravi Sagar _Sparxsys_
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.
May 14, 2020

Paste your complete code and also share what type of fields are those in your code.

Varun Nelluri May 16, 2020

@Ravi Sagar _Sparxsys_ , When specific value selected on Cascading field(Problem code), Test fields should hid or show on the create screen. I am using below code(No errors on the code), not working for me. Could you please help me with this.

Field Types: 

"ProblemCode" - Cascading field

"Callsamples" - Text field

"StepstoReproduce" -  Text field.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.customfields.option.Options

def StepstoReproduce = getFieldByName("Steps to Reproduce")
def Callsamples = getFieldByName("Call samples")
def ProblemCode = getFieldByName("Problem Code")
//create map


Map cfVal = ProblemCode.getValue() as Map


if(cfVal.get(0) == "XXXXX")
{
Callsamples.setHidden(false)
StepstoReproduce.setHidden(false)
}

if(cfVal.get(0) == "YYYYY")
{
Callsamples.setHidden(true)
StepstoReproduce.setHidden(false)
}

if(cfVal.get(0) == "ZZZZ")
{
Callsamples.setHidden(false)
StepstoReproduce.setHidden(true)
}

if(cfVal.get(0) == null)
{
Callsamples.setHidden(true)
StepstoReproduce.setHidden(true)
}

Varun Nelluri May 20, 2020

@Ravi Sagar _Sparxsys_ , Did you had a chance to look at the script i have shared above?

0 votes
Ryan Zore
Contributor
December 17, 2018

Thanks, I was hoping there would be an option in the product itself.  

 

Have you used this for a similar situation?

Nic Brough -Adaptavist-
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.
December 17, 2018

It's one of the reasons the behaviour module in Scriptrunner was written - because Jira does not have functions to show/hide fields.

A lot of people use Behaviours for this.

0 votes
Nic Brough -Adaptavist-
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.
December 15, 2018

You will need to install something like Scriptrunner, to enable you to inject code on the front-end that can show and hide fields depending on the content of others.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events