Hi Team,
Recently I have resolved a task that i have by using the script runner plugin Behavior .
when we select an "Ticket System" and "Other" option in Select List(single choice) a Text field have to appear this is the task that i have resolved here is the link please refer : https://community.atlassian.com/t5/Jira-discussions/In-Select-List-Single-Choice-customfield-selecting-an-Option/m-p/917813#M5103
here is the Script that i have used
def otherFaveField = getFieldByName("Name Of TextField") //Give a text field custom field name that you have created
def faveFruitField = getFieldById(getFieldChanged())
def selectedOption = faveFruitField.getValue() as String
def isOtherSelected = (selectedOption == "Other" || selectedOption == "D") //instead of Other/D You can give another option that you want
otherFaveField.setHidden(! isOtherSelected)
otherFaveField.setRequired(isOtherSelected)
so every thing is fine now here when I select the Other option the text field is appearing and i'm entering an Text in the Text fields and i'm creating ticket .
after creating ticket when i edit the Selected List(Single Choice) field and selecting another option still the Text Field is showing.
Here i want when i change the Select Filed the text field should be empty.
please can anyone help in script.
Thanks,
Phani
Hi,
Did you try using the Behavior Plugin - which is now part of ScriptRunner?
Fo to Administration--> Add-Ons --> Behaviors.
Add a new Behavior.
Once your behavior is created, click on the Fields link for that behavior:
In the Add field drop-down, select your field you want to act as the trigger (so - you will be selecting the "Ticket System" field)
Once you have added your field, click on the Add Server-side script link to provide the ScriptRunner editor.
Here input your code for what should happen when changes are made to the dropdown.
Modify the customfield IDs per your instance.
if(getFieldById("customfield_11111").getFormValue().toString().equalsIgnoreCase("Other")){
getFieldById("customfield_22222").setHidden(false)
getFieldById("customfield_22222").setRequired(true)
}else{
getFieldById("customfield_22222").setRequired(false)
getFieldById("customfield_22222").setHidden(true)
}
I would also recommend create an initialiser.
This basically defines how your screen should appear on initial launch. Here you can set the test box to hidden and default the value of your select list.
Once you are done, make sure to create a mapping.
A Mapping defines when and where the behavior should be active. (Example: Which project, issue type, etc..)
Hi @Gundlupet Sreenidhi thanks for your response so here when i select "Other" and "Ticket system" from Select list custom field the text field has to populate
the above you suggest only "Other" option so I need to add the Ticket system option in that script so how can i add that in the script can you please tell me
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gundlupet Sreenidhi I have tried the script that you have suggested its not working actually even when i select the Other option the Text Field is not appearing
With My script That i posted earlier with that the drop down list when i select "Ticket system" and "Other" option the Text field is appearing .
But when i edit the ticket and when i change the dropdown list with rest any of the option the Text i have entered when i select "Other" is still showing
I want when i change the dropdown list the the text field supposed to disappear automatically see the below pics
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kumar
It is very important that you create the mapping properly. Make sure you select the project and issue type correctly - you will be able to use this setting only on those projects & issue types. (Yes - it is possible to open it to all projects and all issue types)
Also, I guess I forgot to reset the field in my previous thread.
When the value of your select list is not other, then the value of the text box must be reset.
I have also shown an option to check for multiple values in the select list.
//customfield_11111 is your select list field
//customfield_22222 is your text field
//modify the customfield IDs per your instance.
if(getFieldById("customfield_11111").getFormValue().toString().equalsIgnoreCase("Other")
|| getFieldById("customfield_11111").getFormValue().toString().equalsIgonreCase("Something") ){
getFieldById("customfield_22222").setHidden(false)
getFieldById("customfield_22222").setRequired(true)
}else{
getFieldById("customfield_22222").setFormValue("")
getFieldById("customfield_22222").setRequired(false)
getFieldById("customfield_22222").setHidden(true)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gundlupet Sreenidhi I have tried as you suggested and the I have mapped to single project and all issue types.
I have created field i gave the name and i clicked on Field-->Guide Workflow i select the project work flow---->add filed i selected the drop down custom field which i have--->add script that you have shared i the script after the " || " i got an error whole line
I have change the Id's of custom filed and agter that I have mapped to particular project an all issue types
still its not working the text filed is showing default foe all options below the script that i have modified as you suggested
//customfield_10026 is your select list field
//customfield_10864 is your text field
//modify the customfield IDs per your instance.
if(getFieldById("customfield_10026").getFormValue().toString().equalsIgnoreCase("Other")
|| getFieldById("customfield_10026").getFormValue().toString().equalsIgonreCase("Ticket system") ){
getFieldById("customfield_10864").setHidden(false)
getFieldById("customfield_10864").setRequired(true)
}else{
getFieldById("customfield_10864").setFormValue("")
getFieldById("customfield_10864").setRequired(false)
getFieldById("customfield_10864").setHidden(true)
}
can you please take a look and let me know please
and please take look that pics that i attached the Text filed should appear only when i select Ticket system and other option so if i gave any text in text filed even after when i edit the source to email option the text is still showing
sorry for repeating same thing i just want to make sure that you got my point that's it
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Phani,
I understand what you are saying. I implemented the same and here is what I have.
(Small change to the code)
//customfield_12003 - Data Change Exception
//customfield_12004 - Other Description
if(getFieldById("customfield_12003").getValue().equals("Other")){
getFieldById("customfield_12004").setHidden(false)
getFieldById("customfield_12004").setRequired(true)
}else{
getFieldById("customfield_12004").setFormValue(null)
getFieldById("customfield_12004").setRequired(false)
getFieldById("customfield_12004").setHidden(true)
}
Access this link to see how the above code works: https://www.youtube.com/watch?v=o2st9pGV3BE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The following is for checking against different values:
If value is "something" or "other", then the text box will show, else it will not show.
//customfield_12003 - Data Change Exception
//customfield_12004 - Other Description
if(getFieldById("customfield_12003").getValue().equals("Other")
|| getFieldById("customfield_12003").getValue().equals("Something")){
getFieldById("customfield_12004").setHidden(false)
getFieldById("customfield_12004").setRequired(true)
}else{
getFieldById("customfield_12004").setFormValue(null)
getFieldById("customfield_12004").setRequired(false)
getFieldById("customfield_12004").setHidden(true)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gundlupet Sreenidhi now its working great and after creating ticket also when i changed source with other option the text field is disappeared with text
This is small behavior that i have added
//customfield_12003 - Data Change Exception
//customfield_12004 - Other Description
if(getFieldById("customfield_12003").getValue().equals("D")
|| getFieldById("customfield_12003").getValue().equals("Other")){
getFieldById("customfield_12004").setHidden(false)
getFieldById("customfield_12004").setRequired(true)
}else{
getFieldById("customfield_12004").setFormValue(null)
getFieldById("customfield_12004").setRequired(false)
getFieldById("customfield_12004").setHidden(true)
}
thanks for your help @Gundlupet Sreenidhi
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gundlupet Sreenidhi I have raised and another issue can you please look it once here is the link that i have posted new issue
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.