how to add auto complete rendere to any custom field

Kanishk Choraria September 5, 2012

what should i do, to add auto complete to any of my custom field. Any idea..?

I cannot see even auto complete renderer in drop down in field configuration drip down where we have

1. Default text renderer and

2. Wiki Type renderer

Please suggest.

7 answers

1 accepted

1 vote
Answer accepted
Harry Chan
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.
September 5, 2012

Hi, this isn't currently available. You cannot select it for custom fields. What type of custom field are you trying to create? A select list?

You can inject some javascript in the description to get this to work for select/multi-select fields.

Kanishk Choraria September 5, 2012

I have two scenarios:

1. I already have custom field which iis of type JIRA Multiple Database Field (Can query a database and list the results for selection in an issue) and now i need to change it to auto complete

2. I want to create a fresh custom field, so how can i make it "auto-complete" simlar to what we have in "components" field in JIRA.

My sole motive is to creata "auto-complete" custom field..!! so if you can tell me any possible way or scenario through which i can implement it . I will be more th a happy.

I hope i am clear to you..

Thanks

Harry Chan
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.
September 5, 2012

Here is the code we used to get multi-select lists working to look like the new autocomplete renderer:

<script type="text/javascript">
(function($) {
    AJS.$("#customfield_<id> option[value='-1']").remove(); //Removes the default value "None"
    function convertMulti(id){
        if (AJS.$('#'+id+"-textarea").length == 0){
            new AJS.MultiSelect({
                element: $("#"+id),
                itemAttrDisplayed: "label",
                errorMessage: AJS.params.multiselectComponentsError
            });
        }
    }
 
    AJS.toInit(function(){  
        convertMulti("customfield_<id>");
    })
 
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
        AJS.$("#customfield_<id> option[value='-1']").remove();
        convertMulti("customfield_<id>");
    });
})(AJS.$);
</script>

It goes in the description field in the field configuration of a customfield. Replace the customfield id with your own one. I won't take credit for this. We found this post by another user earlier.

Kanishk Choraria September 5, 2012

Still not able to figure out..

can you please have a look at attached screenshots..

where i am missing .??

it would be really greatful.

Thanks

Harry Chan
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.
September 5, 2012

What do you get on the screen where you try to enter data for this field? What shows up?

Kanishk Choraria September 5, 2012

oops.. i think we can add only 3 attachments here as i added five..!!

neways what i get on my create issue screen is as follows:

Kindly suggest.!!!

1 vote
Eric Thn April 15, 2013
Successfully used this as field description
Provides "None" value, which disappears when selecting any (or multiple) other value(s), and re-appears when removing all previously select values
Can be used multiple times in a single page (multiple multi-select fields with same script as description)
 
Single issue found :
if you are on the [jira-instance]/secure/CreateIssue.jspa page AND if you click "Create issue" on top right of the screen, the concerned fields just become non-working fields.
<script type="text/javascript">
jQuery(document).ready(function(){
	console.log('Loaded');
	jQuery.getScript('http://cdnjs.cloudflare.com/ajax/libs/chosen/0.9.12/chosen.jquery.min.js', function(data, textStatus, jqxhr) {
   	jQuery("select[id^='customfield'][multiple='multiple'] option[value=-1]").html('Aucun'); // replace Label for "None" when necessary
	jQuery("select[id^='customfield'][multiple='multiple']").data('chosen', null);
	jQuery("select[id^='customfield'][multiple='multiple']")
		.chosen({no_results_text: "Aucun résultat : ", placeholder_text_multiple: " ", single_backstroke_delete: true})
		.change(function() {if (jQuery(this).val()!=null)
			{
				if(jQuery(this).val().length>1 && jQuery(this).val()[0] == '-1'){jQuery('#'+jQuery(this).attr("id")+' option[value=-1]').removeAttr("selected").trigger("liszt:updated");}}
				else{jQuery('#'+jQuery(this).attr("id")+' option[value=-1]').attr("selected", "selected").trigger("liszt:updated");
			}
		});
});
	if(jQuery("body").size()>0){if (document.createStyleSheet){document.createStyleSheet('http://cdnjs.cloudflare.com/ajax/libs/chosen/0.9.12/chosen.css');}
    else {jQuery("head").append(jQuery("<link rel='stylesheet' href='http://cdnjs.cloudflare.com/ajax/libs/chosen/0.9.12/chosen.css' type='text/css' media='screen' />"));}}

});
</script>

Successfully used this as field description

Provides "None" value, which disappears when selecting any (or multiple) other value(s), and re-appears when removing all previously select values

Can be used multiple times in a single page (multiple multi-select fields with same script as description)

Single issue found :

if you are on the [jira-instance]/secure/CreateIssue.jspa page AND if you click "Create issue" on top right of the screen, the concerned fields just become non-working fields.

0 votes
meena bhujang August 29, 2013

hi all,

i am trying to use the same script to work for me. I copied the same script above and pasted in the field description box. and replaced custom_<id> with my own custom_field id. But it is not working after re-indexing. please help.

0 votes
Kanishk Choraria August 7, 2013
test anser your own question as i want to close it. one of the solution suggested by Atlassian to close the question is : ->Answer your own question, then accept your answer (find the 'Answer my own question' link underneath your question) but still I am not able to, can anyone help?
0 votes
Kanishk Choraria July 21, 2013

THank s guys, although was not able to figure out exact answer but management has chnaged the requirement.

So now I do not need it as of now..!! But wil definitely post its answer very soon as I am digging things here and there only. Forget to close it before. Apologies for that

Thanks for the efforts and suggestions . It made me true fan for atlassian answers club.

0 votes
IshanL
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.
July 4, 2013

@Harry Chan, your comment was very useful indeed . Thanks

0 votes
Florin Manaila
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.
September 5, 2012

Hi,

Take a look at https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.databasecf

It provides the autocomplete functionality out of the box.

Suggest an answer

Log in or Sign up to answer