AI Search and Scripted Search Sources
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 07:31 AM
We've recently migrated our Service Portal from the legacy service portal (sp) to something based off the new Employee Service Center (esc) and one of the things that isn't working as well as we had expected is the AI Search.
In the legacy search, you could have a scripted search source (sp_search_source) that would allow you to script out the data fetch script. Using the legacy method, we had built a way for users to view someone else's ticket on the Service Portal by entering in the explicit ticket number. The Data Fetch Script allowed us to determine what values were being passed to the search function, and, if the search did not start with a ticket prefix (INC, RITM, REQ) we appended additional search parameters to ensure users could only browse their own tickets, but, if it started with a prefix, and that ticket existed, it let them find that ticket in the search results.
See the below code snippet from the sp_search_source as an example for Incident tickets:
(function(query) {
var results = [];
var ticketGR = new GlideRecord('incident');
ticketGR.addQuery('IR_AND_OR_QUERY', query);
if (query.indexOf('INC') == -1){
var user_reference = ['caller_id', 'opened_by', 'closed_by', 'u_alternate_contact', 'assigned_to'];
var q = user_reference[0] + '=' + gs.getUserID();
for (i = 1; i < user_reference.length; i++)
q += '^OR' + user_reference[i] + '=' + gs.getUserID();
q+='^ORwatch_listCONTAINS'+gs.getUserID();
q+='^ORshort_descriptionCONTAINS'+gs.getUserDisplayName()+'^ORdescriptionCONTAINS'+gs.getUserDisplayName();
ticketGR.addEncodedQuery(q);
}
ticketGR.orderBy('state');
ticketGR.query(q);
while (ticketGR.next()) {
item = {};
item.primary = ticketGR.number + ': ' + ticketGR.short_description.toString();
item.number = ticketGR.number.toString();
item.table = 'incident';
item.sys_id = ticketGR.getUniqueValue();
item.fields = getSecondary(ticketGR, ['number', 'state', 'caller_id', 'opened_by', 'description']);
results.push(item);
}
function getSecondary(record, fields) {
var fields_data = [];
for (i = 0; i < fields.length; i++) {
var data = {};
data.label = record.getElement(fields[i]).getED().getLabel();
data.display_value = record.getDisplayValue(fields[i]);
if (data.display_value != '')
fields_data.push(data);
}
return fields_data;
}
return results;
})(query);
So, if they looked for 'Password Reset', they would only see their own password reset incidents, but if they looked up INC123456, they would see that ticket as a search result.
However, in the NEW search, we don't seem to have that ability. The Indexed Source record determines which records get ingested by the AI Search engine, and the Search Source (ais_search_source) only allows limited conditions built in a filter to determine what will come back for a user. And even that filter is limited. You can add 'Caller Is (dynamic) Me' but not 'Watch List Is (dynamic) Me' or even 'Assignment Group Is (dynamic) One of my groups', and there seems to be no way to interrupt the query being run to skip those additional parameters if the user enters a ticket number. If we remove the filter on ais_search_source, then all searches search all sources; 'INC123456' will find that ticket, but 'password reset' will show a user EVERYONE'S password reset Incidents.
So, using the AI Search, how would we allow for the equivalent of the Scripted Search Source, allowing a user to find any ticket by number, but limiting their search if they aren't searching for a specific ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 04:39 PM
Hi Jacob, have you found any solutions using AI search