Going through the event listeners attached to the autocompletion insights field, a missing implementation of handling query attribute, required by autocomplete endpoint is evident.
This issue is due to missing the required "query" attribute as a part of the payload for autocomplete endpoint:
https://x-y-z.atlassian.net/rest/servicedesk/cmdb/1/field/customfield_10166/config/10319/autocomplete
The issue appears to surface originally in the incubateRequest function calling up Json Object string serializer via data() function which is passed in incubateRequest in
module-key = 'jira.webresources:select-pickers', location = '/includes/ajs/select/fetchers/ajax-descriptor-fetcher.js'
Please note the line:
if (typeof ajaxOptions.data === 'function') {
ajaxOptions.data = ajaxOptions.data(query);
}
Code for the incubateRequest:
/**
* Prepare the data and prevent throttling of server
* @param {jQuery.Deferred} deferred
* @param {Object} ajaxOptions - standard jQuery ajax options
* @param {String} query - in most cases this is the user input
* @param {Boolean} force - ignore request buffers. I want my request dispatched NOW.
*/
incubateRequest: function(deferred, ajaxOptions, query, force) { clearTimeout(this.queuedRequest); this.outstandingRequest.abort();
this.outstandingRequest = null;
} if (!ajaxOptions.query && this.lastResponse) {
deferred.resolve(this.lastResponse);
} else if (!this.outstandingRequest) {
if (typeof ajaxOptions.data === 'function') {
ajaxOptions.data = ajaxOptions.data(query);
} else {
ajaxOptions.data.query = query;
} if (typeof ajaxOptions.url === 'function') {
ajaxOptions.url = ajaxOptions.url();
} if ((query.length >= parseInt(ajaxOptions.minQueryLength, 10)) || force) {
this.makeRequest(deferred, ajaxOptions, query);
} else {
deferred.resolve();
}
} else {
this.queuedRequest = setTimeout(_.bind(function () {
this.incubateRequest(deferred, ajaxOptions, query, true);
}, this), ajaxOptions.keyInputPeriod);
} return deferred;
},
the ajaxOptions.data is a function reference, initialised via 'jira.webresources:select-pickers' module init, and is missing implementation of handling the passed in query parameter.
Please refer to the data function implementation in
module-key = 'com.atlassian.servicedesk.frontend-webpack-plugin:context-jira.create.issue', location = 'jira.create.issue.bundle.js'
As you can see in the code snippet below, there is no query argument passed into inline function, and the implementation is just to return a json object of all form fields.
ajaxOptions: {
...
data: function() {
return JSON.stringify(m())
}
}
Implementation of data() function in other modules (user picker for example) includes appending query attribute.
Example for User Picker data handler (this is just for your reference, on how the insights autocomplete "data" handler could have been implemented
function data(query) {
r.actionDescriptorId = void 0,
g();
var data = {
projectKeys: r.projectKeys,
issueKey: r.assigneeEditIssueKey,
actionDescriptorId: r.actionDescriptorId,
maxResults: 50,
startAt: 0 === h._pagination.numberOfShowingItems ? 0 : h._pagination.numberOfShowingItems + 1
};
return p(data, query)
}
function p(data, query) {
return u.extend({
query: query
}, data)
}
I have tested by modifying inflight request payload to the autocomplete endpoint, with the additional query attribute, and autocompletion returns a number of elements (less then stated 50) filtered by the query parameters.
Hi owessels ,
Just an update to tie up any loose ends. I have feedback from the customer regarding what they are seeing:
So it is as you described and working as designed
Thank you!