I want to remove some options (based on a rule) from a multiversion picker field . How can this be done ?
Any javascript/groovy script example will be highly appreciated.
I tried to set options to a multiversion picker using Behaviours plugin but at present that is not working, have a look at this issue and this question .Using behaviours plugin to set options to a fields is what i want but since i have to do this as early as possible can some one please guide me on how i can remove option from a multi version picker field.
Suggestions , comments welcomed
Thank you :)
Community moderators have prevented the ability to post new answers.
to remove options from version picker(following script is for jira 5.0)
<script type="text/javascript">
jQuery(document).ready(function($) {
removeOption();
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
removeOption();
});
function removeOption(){
$("#versions option").each(function() {
if( $(this).val() == 'optionid' || add here condition to remove other options){
$(this).remove();
}
});
}
});
</script>
let me know if you have any questions
Cheers,
Thanks for your answer . i need a script for 4.3.2 and 4.4.4 . can there be a similar script for these versions of jira ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried the above script in Jira 5.0 but the options remain same . i pasted the script in the description of a mutliversion picker customfield and provided a valid option id however the option is visible in the field on create issue screen and other screens .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We're trying the script in JIRA 4.4.4 and it's working perfectly - many thanks for this, we've been puzzling over how to do it for ages!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Mizan,
it should work on Jira 5.0, can you test weather javascript is loading on create screen by giving some alert and let me know you have any issues.
Cheers,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rambanam ,
I gave an alert but the alert appears as soon as i update the script on the field and not on the create issue screen .Do you know why this is happening ?
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.
Mizan,
if you want it work do it as follows and test
1.in create screen seelect the project and issue type
2. come out of create issue popup window and refresh the browser
3. open the create issue popup
now i think 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 Dieter ,
When i put a alert in announcement banner , whenever the page reload i see a alert box , what should i do to make the script run normally on create and transition screens for a field ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
alternatively add the JavaScript under description of custom field which will be in all issue type create screens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The customfield is in all issue type create screens , this script works for Alex Taylor as he has mentioned in the above comment
The option id is the version id of the option right ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if it worked cool, yes ur correct option id is the version id.
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.
I pasted the exact script in announcement banner and still it does not work .
i insert the script in the description of the customfield
the script automatically appears in the description of the field in field configuration
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The script in this documentation works properly , Is there something i am missing ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
sorry for my one of my previes comment saying like adding javascript under custom field description.
i tested now by adding same javascript under field descption in field configuration it worked fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dont know why its not working in my jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
tried even on a new Jira 5.0 :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
strange. this doesn't work for me as described. when i use a drop-down box in create issue dialog, there is no JIRA.Events.NEW_CONTENT_ADDED fired for me. AJS.$(document).ready(function() { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { alert('more content added'); }); }); using this, the alert is coming up once, when i open create issue dialog. Inside the dialog it never triggers again, when i change any content on the dialog.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<script type="text/javascript"> AJS.$("#versions option").each(function() { if( AJS.$(this).val() == 'optionId'){ AJS.$(this).remove(); } }); </script>
Works for me in 4.4.3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin ,
Thanks for the script but due to some reason scripts are not running on my Jira . When i give an alert, instead of appearing on the create and transition screens the alert appears as soon as i update the script on the customfield description.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now the alert appears on the issue create screen when i save the script in the description of field configuration
<script type="text/javascript"> AJS.$("#versions option").each(function() { if( AJS.$(this).val() == '10100'){ AJS.$(this).remove(); alert("HI"+AJS.$(this).val()) } }); </script>
On the issue create screen i get an alert "HI10100" but the option exists in the multiversion picker.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mizan,
You said a multi version picker. That means it is a custom field? If so, the srcript needs to be slightly changes to use the custom field id instead of #versions.
The above script is to hide the option from 'Fix Version'. See if that is working first ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One more question , instead of OptionId can i check optionName ? if yes how ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah at last that option is removed :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try AJS.$(
this
).text() instead of
AJS.$(
this
).val(). Actually, do an alert first as I haven't tried it before ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it works . thanx :) but not able to compare it with the version name eg:if
( AJS.$(
this
).text() ==
'test'
) not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
( AJS.$(
this
).text().trim() ==
'test'
) works :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin ,
The above script does not work with IE8 (javascript enabled)
<script type="text/javascript"> AJS.$("#versions option").each(function() { alert("i am in each") if( AJS.$(this).val() == '10100'){ alert("i am in if") AJS.$(this).remove(); alert("HI"+AJS.$(this).val()) } }); </script>
i get an alert "i am in each" but not the second alert
the script works fine in FF and Chrome
Can you hlp me with this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dbconfig.xml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use any one of the following
$(this).find("option:selected").text(); or $("#yourdropdownid option:selected").text();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Doing that I get the text of all options concatened, and I'd like to get only the text of the option selected, and for it firstly I need to access the option, and then get the value
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
I wanted to know how can I access to the text of the option instead of its value. Any idea?
for example
<option value='001'>Opción 1</option>
'Opción 1' is the thing I want to recover
Thank you very much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
$(this).text()
If this does not help you should ask a new question .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.