The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Editing a select list -custom field with options - instead of the default one's

saravanan subramanian
Contributor
September 7, 2011

Hi All,

My select list custom field has default options, 1,2,3,4,5 , but i want to display only 1, 3 and 5 when i posted that question a user told me that i can write a java script by editing the custom field.

I tried it but it was not working, is any one has a sample that i can use or any other methods that i can use , please let me know. Editing the edit-select.vm file is also not working because i dont see those options and the custom field id in that file

Please help me out

Saran

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
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 Champions.
September 7, 2011

First, make sure you have 1, 2, 3, 4 and 5 as the options - the principle here is to get Jira to serve up all of the options, and then remove the ones you don't want after it's rendered.

Second, you didn't say where your javascript is, or how you've embedded it, but the way to do it in off-the-shelf Jira is to add it to the description of a custom field. I've had problems doing that sometimes, unless I added it to the last field appearing on the screen. You could also add it to select.vm or maybe use message fields, but the other methods all require coding or plugins.

Third, some simple code

{code}

<script language="JavaScript" type="text/javascript">
<!--
window.onload = function()
{
var listBox = document.getElementById("customfield_10312");
if (listBox)
{
for (j = listBox.length - 1; j>=0; j--)
{
if (listBox.options[j].value=="2") { listBox.remove(j); }
if (listBox.options[j].value=="4") { listBox.remove(j); }
}
}
}
// -->
</script>

{code}

saravanan subramanian
Contributor
September 7, 2011

Thank you

It worked. Thanks again

Saran

TAGS
AUG Leaders

Atlassian Community Events