Hello Team,
I would need a suggestion here. How do I control the visibility of one field based on other field value selection on create screen.
Example:
I have a field in create screen named as "Additional Itinerary" which is checkbox field.
It has values say 1, 2, 3 4, 5
I also have fields in create screen named as "Amount", "Cash"
Now, If value in "Additional Itinerary" field is selected as "1", only then the field "Amount" should be displayed in Create screen.
How can I achieve this ?
I have script runner plugin with me, can we do it with script runner. Please advise ?
Hi @murthy manjunath , you can achieve this via Scriptrunner Behavior, I assume that you want it on customer portal because you say upon creation. I will give you a sample code to start with.
def addItenerary = getFieldByName("Additional Itenerary") // customfield name
def amount = getFieldByName("Amount") // amount field
def cash = getFieldByName("Cash") // cash field
def addValue = addItenerary.getValue()
if (addValue == 1) {
amount.setHidden(false)
cash.setHidden(true)
}
you can add more if else statement , depending on your needs.
Hope this helps
Alvin
Hi Alvin,
Thank you for taking time to assist.
I tried your suggestion, but the fields are not hidden. Please see the screenshot below if i am doing it correct ?
"Additional Itinerary" is the field which has value called "Forex". If this value is selected only then the fields named "Forex Card Amount" and "Forex Cash" should be displayed, else these fields should not be displayed.
Fields in create screen Screenshot:
Regards,
Murthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @murthy manjunath , put the code on the server side , not on the initialiser. select your custom field on Add Field , put Additional Itenerary then place the code
Hope that helps
Best Regards,
Alvin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alvin,
Thank you, I put the script in server side script by choosing field Additional Itinerary. However, here is the problem i am noticing.
Moment I select the checkbox value as anything other than "Forex", the fields are hidden. Later if I check the checkbox "Forex" fields are still hidden and does not display.
Here is the condition I am looking for;
If checkbox value of "Additional Itinerary" field contains value "Forex", then the custom fields "Forex Card Amount", "Forex Cash", "Currency Requirement" should be displayed.
If "Forex" checkbox is not selected then it should stay hidden.
Screenshots of code an screens attached for reference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @murthy manjunath , do the else statement for the following scenarios. just follow the format, I didn't test it but it should work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Alvin
Did I miss anything from your previous comments, I do not see the scenarios as you have mentioned. Please assist.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @murthy manjunath , what I mean is you do the else statement based on your scenario
else {
anyfield.setHidden(true)
anyfield1.setHidden(true)
}
like this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
yes you can do it with Behaviour
https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.