Search Source configured to find a specific field on my incident table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:12 AM
I am trying to allow my users to perform a search on a specific field and get all results that have that searched for field.
For example I have a store which has a store number (123). I want my users to be able to bring up the search page in my portal and enter store #123 and the results will be all incidents for store #123.
I have already created a search source specifically for my incident table.
Domenic
- Labels:
-
Field Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:41 AM
you can create new search source for portal with data fetch script something like
(function(query) {
var results = [];
/* Calculate your results here. */
if (!gs.isLoggedIn())
return results;
var inc = new GlideRecord('incident');
inc .addEncodedQuery('u_storeLIKE'+query);
inc .query();
var catCount = 0;
while (inc.next() && catCount < data.limit) {
if (!$sp.canReadRecord(inc))
continue;
var item = {};
item.type = "inc";
item.page = "ticket";
$sp.getRecordDisplayValues(item, inc, 'number,short_description,sys_id');
item.label = item.number;
item.primary = item.number;
results.push(item);
catCount++;
}
return results;
})(query);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:46 AM
I am not a developer so please forgive the questions. Where do I insert the incident table parameter I am searching and the field?
The field that I want the search to be based on is u_store_location

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:59 AM
I inserted the code into the script source and changed one parameter which is in BOLD and Underlined.
However I am still not getting back results for the store number I entered on my search. Instead now I am getting random incident tickets and when I click the link to go to the ticket my next screen is blank.
(function(query) {
var results = [];
/* Calculate your results here. */
if (!gs.isLoggedIn())
return results;
var inc = new GlideRecord('incident');
inc .addEncodedQuery('incident.u_store_location'+query);
inc .query();
var catCount = 0;
while (inc.next() && catCount < data.limit) {
if (!$sp.canReadRecord(inc))
continue;
var item = {};
item.type = "inc";
item.page = "ticket";
$sp.getRecordDisplayValues(item, inc, 'number,short_description,sys_id');
item.label = item.number;
item.primary = item.number;
results.push(item);
catCount++;
}
return results;
})(query);