AI Search: Get search results as JSON by running a script from scripts background


Description

Getting AI search results using a script can be an effective troubleshooting tool that can help in scenarios like:

Release or Environment

Quebec+

Instructions

Here is the sample script that can be used to get the results for the OOB "Service Portal Default Search Application" configuration:

//Make changes to the searchParams based on your requirements. Just need to change searchContextConfigId and searchTerm to get started.

searchParams = {
 searchContextConfigId: '00731b9d5b231010d9a5ce1a8581c7dd',    //sys_id of the Search Application configuration[sys_search_context_config] record that you want to use for searching.
 searchTerm: '***',              // The search term *** returns all records that have been indexed.
 paginationToken: '',             // Leaving paginationToken empty returns the data for the first page. To get the paginationToken for 2nd page, click the next page button on the portal after doing the search and check the URL for paginationToken.
 disableSpellCheck: false,
 facetFilters: [],
 searchFilters: [],
 requestedFields: {},
 rpSysId: 'test'                    // Just a dummy value that is needed for the script to work.
};

var aiSearchUtil = new AISASearchUtil();
var result = aiSearchUtil.search(searchParams);

var searchResult = result.data.search.searchResults;

gs.info(searchResult.length);

for (var i=0; i<searchResult.length; i++){
gs.info(searchResult[i].title + " | " + searchResult[i].text);
}

gs.info(JSON.stringify(result));

Note: Ensure that search sources have been indexed before trying to search.

Sample Output:

*** Script: 10
*** Script: Intro-AI-Search-Labs.pdf | © 2021 ServiceNow, Inc. All rights reserved. CONFIDENTIAL. ServiceNow, the ServiceNow logo, Now, Now Platform, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc. in the United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are associated. 1 Introduction to AI Search Lab 0 - Enable AI Search and Configure Genius Results 15 minutes Table of Contents Lab objectives ............................................................................................................................................. ...
*** Script: Automatic Replies (Out Of Office) | Automatic Replies (Out Of Office) This article explains how to use automatic replies in Outlook 2010 for Exchange accounts. Setting Up Automatic Replies Click the File tab. Click Automatic Replies. Select Send automatic replies. If desired, select the Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the Do not send automatic replies check box. On the Inside My Organization tab, ...
*** Script: Email Interruption Tonight at 11:00 PM Eastern |  If the site is UP but you cant access the page, try one of the below solutions: Browser Related Problems Force a full refresh for the site. This can be achieved by pressing CTRL + F5 keys at the same time on your favourite browser (Firefox, Chrome, Explorer, etc.) Try alternative urls such as m.outlook.com Clear the temporary cache and cookies on your browser to make sure that you have the most recent version of the web page. For instructions choose your brow Fix DNS Problems A Domain Name System ...
*** Script: Sales Force Automation is DOWN |   On Friday, January 20th, we experienced a widespread outage that affected all Zoho services. The outage started around 8:13 am Pacific Time. Zoho services started coming back online for customer use at 3:49 pm, and all services were fully restored at 6:22 pm PST. We absolutely realize how important our services are for businesses and users who rely on us; we let you down on Friday. Please accept our humblest apologies.    The cause of the outage was an abrupt power failure in our state-of-the-art ...
*** Script: Eclipse configuration for Android development | Installing the Eclipse Plugin Android offers a custom plugin for the Eclipse IDE, called Android Development Tools (ADT). This plugin provides a powerful, integrated environment in which to develop Android apps. It extends the capabilities of Eclipse to let you quickly set up new Android projects, build an app UI, debug your app, and export signed (or unsigned) app packages (APKs) for distribution. Note: If you have been using Eclipse with ADT, be aware that Android Studio is now the official IDE ...
*** Script: Warranty coverage details for SCI and DeSC computers | Warranty coverage details for SCI and DeSC computers   Your newly acquired Dell computer comes with a limited factory warranty of 5 years for parts and labor coverage. The warranty begins the day the computer is shipped, not when you receive it.  If you think that you have a hardware problem and are not sure, please call the OIT Help Desk at 8-HELP. A Help Desk representative will determine if the problem is caused by hardware or software. If it is determined to be a hardware problem, a Hardware ...
*** Script: Excel Functionality | Excel Functionality Copying formulas without changing cell locations When you want to know how to copy a formula and keep portions of the formula from changing relative to where they are being copied, p recede each portion of the cell specifications that aren't supposed to change with $. For example, if a formula contains the cell reference: B2, which is not supposed to change if the formula is copied to another cell, then change B2 to $B$2 If, for example, the column specification, B, can change ...
*** Script: Dealing with Spyware and Viruses |   Dealing with Spyware/Adware Spyware is the generic term for computer software that gathers information about you and your Internet surfing habits for marketing purposes; Adware refers to programs which gather information about you for marketing purposes in order to target your computer with advertisements (often in the form of pop-up windows.) These programs are often difficult to uninstall through traditional un-installation programs and will interfere with the normal performance of your computer's ...
*** Script: Create And Edit A Contact Group | Outlook 2010 - Create And Edit A Contact Group (Formerly Distribution Lists) This article explains how to create and edit a contact group in Outlook 2010. In previous versions of Outlook, this was known as a distribution list. A contact group (formerly known as a distribution list) is a grouping of email addresses collected under one name. A message sent to a Contact Group goes to all recipients listed in the group. You can include Contact Groups in messages, task requests, meeting requests, and ...
*** Script: Microsoft Outlook Issues | Microsoft Outlook Issues This article explains how to use automatic replies in Outlook 2010 for Exchange accounts. Setting Up Automatic Replies Click the File tab. Click Automatic Replies. Select Send automatic replies. If desired, select the Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the Do not send automatic replies check box. On the Inside My Organization tab, ...
*** Script: {"status":200,"msg":"SUCCESS","data":{"search":{"term":"***","count":10,"searchResults":[{"sysId":"cb0a8117db1a3410d74bb8e2f3961977","table":"sys_attachment","text":"© 2021 ServiceNow, Inc. All rights reserved. CONFIDENTIAL. ServiceNow, the ServiceNow logo, Now, Now Platform, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc. in the United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are associated. 1 Introduction to AI Search Lab 0 - Enable AI Search and Configure Genius Results 15 minutes Table of Contents Lab objectives ............................................................................................................................................. ... ","title":"Intro-AI-Search-Labs.pdf","columns":[{"fieldName":"sys_id","label":"sys_id","value":"cb0a8117db1a3410d74bb8e2f3961977","displayValue":"cb0a8117db1a3410d74bb8e2f3961977"},{"fieldName":"short_description","label":"Short description","value":"What is the Windows key?\t\t","displayValue":"What is the Windows key?\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"13","displayValue":"13"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"a6826bf03710200044e0bfc8bcbe5de6","displayValue":"Boris Catino"},{"fieldName":"sys_updated_on","label":"Updated","value":"1630813030000","displayValue":"2021-09-04 20:37:10"},{"fieldName":"kb_category","label":"Category","value":"14f8a152ff0131009b20ffffffffff74","displayValue":"Windows"},{"fieldName":"parent_title","label":"parent_title","value":"KB0000017 What is the Windows key?\t\t","displayValue":"KB0000017 What is the Windows key?\t\t"},{"fieldName":"parent_table","label":"parent_table","value":"kb_knowledge","displayValue":"kb_knowledge"},{"fieldName":"parent_sys_id","label":"parent_sys_id","value":"3b07857187032100deddb882a2e3ec20","displayValue":"3b07857187032100deddb882a2e3ec20"},{"fieldName":"doctype","label":"doctype","value":"PDF document","displayValue":"PDF document"},{"fieldName":"doctype_image_type","label":"doctype_image_type","value":"icon","displayValue":"icon"},{"fieldName":"doctype_image","label":"doctype_image","value":"document-template-outline","displayValue":"document-template-outline"}]},{"sysId":"f40da43187032100deddb882a2e3ecc5","table":"kb_knowledge","text":"Automatic Replies (Out Of Office) This article explains how to use automatic replies in Outlook 2010 for Exchange accounts. Setting Up Automatic Replies Click the File tab. Click Automatic Replies. Select Send automatic replies. If desired, select the Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the Do not send automatic replies check box. On the Inside My Organization tab, ... ","title":"Automatic Replies (Out Of Office)\n\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"f40da43187032100deddb882a2e3ecc5","displayValue":"f40da43187032100deddb882a2e3ecc5"},{"fieldName":"short_description","label":"Short description","value":"Automatic Replies (Out Of Office)\n\t\t","displayValue":"Automatic Replies (Out Of Office)\n\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"85","displayValue":"85"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"62d78687c0a8010e00b3d84178adc913","displayValue":"Ron Kettering"},{"fieldName":"sys_updated_on","label":"Updated","value":"1419004215000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"36786152ff0131009b20ffffffffff51","displayValue":"Outlook 2010"}]},{"sysId":"f27d7f79c0a8011b0018f9d700d2b9aa","table":"kb_knowledge","text":" If the site is UP but you cant access the page, try one of the below solutions: Browser Related Problems Force a full refresh for the site. This can be achieved by pressing CTRL + F5 keys at the same time on your favourite browser (Firefox, Chrome, Explorer, etc.) Try alternative urls such as m.outlook.com Clear the temporary cache and cookies on your browser to make sure that you have the most recent version of the web page. For instructions choose your brow Fix DNS Problems A Domain Name System ... ","title":"Email Interruption Tonight at 11:00 PM Eastern\n\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"f27d7f79c0a8011b0018f9d700d2b9aa","displayValue":"f27d7f79c0a8011b0018f9d700d2b9aa"},{"fieldName":"short_description","label":"Short description","value":"Email Interruption Tonight at 11:00 PM Eastern\n\t\t","displayValue":"Email Interruption Tonight at 11:00 PM Eastern\n\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"0","displayValue":"0"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"46d14f04a9fe19810142e40c6b071512","displayValue":"Wayne Webb"},{"fieldName":"sys_updated_on","label":"Updated","value":"1629819823000","displayValue":"1 week ago"},{"fieldName":"kb_category","label":"Category","value":"b85c6552ff0131009b20ffffffffffd4","displayValue":"Announcements"}]},{"sysId":"f2765f9fc0a8011b0120ec1b352bf09b","table":"kb_knowledge","text":"  On Friday, January 20th, we experienced a widespread outage that affected all Zoho services. The outage started around 8:13 am Pacific Time. Zoho services started coming back online for customer use at 3:49 pm, and all services were fully restored at 6:22 pm PST. We absolutely realize how important our services are for businesses and users who rely on us; we let you down on Friday. Please accept our humblest apologies.    The cause of the outage was an abrupt power failure in our state-of-the-art ... ","title":"Sales Force Automation is DOWN","columns":[{"fieldName":"sys_id","label":"sys_id","value":"f2765f9fc0a8011b0120ec1b352bf09b","displayValue":"f2765f9fc0a8011b0120ec1b352bf09b"},{"fieldName":"short_description","label":"Short description","value":"Sales Force Automation is DOWN","displayValue":"Sales Force Automation is DOWN"},{"fieldName":"sys_view_count","label":"View count","value":"0","displayValue":"0"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"46d14f04a9fe19810142e40c6b071512","displayValue":"Wayne Webb"},{"fieldName":"sys_updated_on","label":"Updated","value":"1607443073000","displayValue":"9 months ago"},{"fieldName":"kb_category","label":"Category","value":"b85c6552ff0131009b20ffffffffffd4","displayValue":"Announcements"}]},{"sysId":"e97ee81eff6002009b20ffffffffffe0","table":"kb_knowledge","text":"Installing the Eclipse Plugin Android offers a custom plugin for the Eclipse IDE, called Android Development Tools (ADT). This plugin provides a powerful, integrated environment in which to develop Android apps. It extends the capabilities of Eclipse to let you quickly set up new Android projects, build an app UI, debug your app, and export signed (or unsigned) app packages (APKs) for distribution. Note: If you have been using Eclipse with ADT, be aware that Android Studio is now the official IDE ... ","title":"Eclipse configuration for Android development\n\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"e97ee81eff6002009b20ffffffffffe0","displayValue":"e97ee81eff6002009b20ffffffffffe0"},{"fieldName":"short_description","label":"Short description","value":"Eclipse configuration for Android development\n\t\t","displayValue":"Eclipse configuration for Android development\n\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"2","displayValue":"2"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"6816f79cc0a8016401c5a33be04be441","displayValue":"System Administrator"},{"fieldName":"sys_updated_on","label":"Updated","value":"1434042657000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"c78a2d2047b002007f47563dbb9a71bf","displayValue":"Android"}]},{"sysId":"e31486b5474321009db4b5b08b9a7164","table":"kb_knowledge","text":"Warranty coverage details for SCI and DeSC computers   Your newly acquired Dell computer comes with a limited factory warranty of 5 years for parts and labor coverage. The warranty begins the day the computer is shipped, not when you receive it.  If you think that you have a hardware problem and are not sure, please call the OIT Help Desk at 8-HELP. A Help Desk representative will determine if the problem is caused by hardware or software. If it is determined to be a hardware problem, a Hardware ... ","title":"Warranty coverage details for SCI and DeSC\n\t\t\tcomputers\n\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"e31486b5474321009db4b5b08b9a7164","displayValue":"e31486b5474321009db4b5b08b9a7164"},{"fieldName":"short_description","label":"Short description","value":"Warranty coverage details for SCI and DeSC\n\t\t\tcomputers\n\t\t","displayValue":"Warranty coverage details for SCI and DeSC\n\t\t\tcomputers\n\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"8","displayValue":"8"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"46d14f04a9fe19810142e40c6b071512","displayValue":"Wayne Webb"},{"fieldName":"sys_updated_on","label":"Updated","value":"1419004507000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"455b2552ff0131009b20ffffffffffd9","displayValue":"Dell"}]},{"sysId":"dcf43d75474321009db4b5b08b9a71dc","table":"kb_knowledge","text":"Excel Functionality Copying formulas without changing cell locations When you want to know how to copy a formula and keep portions of the formula from changing relative to where they are being copied, p recede each portion of the cell specifications that aren't supposed to change with $. For example, if a formula contains the cell reference: B2, which is not supposed to change if the formula is copied to another cell, then change B2 to $B$2 If, for example, the column specification, B, can change ... ","title":"Excel Functionality","columns":[{"fieldName":"sys_id","label":"sys_id","value":"dcf43d75474321009db4b5b08b9a71dc","displayValue":"dcf43d75474321009db4b5b08b9a71dc"},{"fieldName":"short_description","label":"Short description","value":"Excel Functionality","displayValue":"Excel Functionality"},{"fieldName":"sys_view_count","label":"View count","value":"2","displayValue":"2"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"a6826bf03710200044e0bfc8bcbe5de6","displayValue":"Boris Catino"},{"fieldName":"sys_updated_on","label":"Updated","value":"1419004583000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"ed1c2552ff0131009b20ffffffffff65","displayValue":"Excel"}]},{"sysId":"d7dc75b5474321009db4b5b08b9a7150","table":"kb_knowledge","text":"  Dealing with Spyware/Adware Spyware is the generic term for computer software that gathers information about you and your Internet surfing habits for marketing purposes; Adware refers to programs which gather information about you for marketing purposes in order to target your computer with advertisements (often in the form of pop-up windows.) These programs are often difficult to uninstall through traditional un-installation programs and will interfere with the normal performance of your computer's ... ","title":"Dealing with Spyware and Viruses\n\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"d7dc75b5474321009db4b5b08b9a7150","displayValue":"d7dc75b5474321009db4b5b08b9a7150"},{"fieldName":"short_description","label":"Short description","value":"Dealing with Spyware and Viruses\n\t\t","displayValue":"Dealing with Spyware and Viruses\n\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"11","displayValue":"11"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"46d14f04a9fe19810142e40c6b071512","displayValue":"Wayne Webb"},{"fieldName":"sys_updated_on","label":"Updated","value":"1419004564000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"6bfb6552ff0131009b20ffffffffff66","displayValue":"Security"}]},{"sysId":"d15de43187032100deddb882a2e3ec7d","table":"kb_knowledge","text":"Outlook 2010 - Create And Edit A Contact Group (Formerly Distribution Lists) This article explains how to create and edit a contact group in Outlook 2010. In previous versions of Outlook, this was known as a distribution list. A contact group (formerly known as a distribution list) is a grouping of email addresses collected under one name. A message sent to a Contact Group goes to all recipients listed in the group. You can include Contact Groups in messages, task requests, meeting requests, and ... ","title":"Create And Edit A Contact Group\t\t","columns":[{"fieldName":"sys_id","label":"sys_id","value":"d15de43187032100deddb882a2e3ec7d","displayValue":"d15de43187032100deddb882a2e3ec7d"},{"fieldName":"short_description","label":"Short description","value":"Create And Edit A Contact Group\t\t","displayValue":"Create And Edit A Contact Group\t\t"},{"fieldName":"sys_view_count","label":"View count","value":"10","displayValue":"10"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"62d78687c0a8010e00b3d84178adc913","displayValue":"Ron Kettering"},{"fieldName":"sys_updated_on","label":"Updated","value":"1419004208000","displayValue":"6 years ago"},{"fieldName":"kb_category","label":"Category","value":"36786152ff0131009b20ffffffffff51","displayValue":"Outlook 2010"}]},{"sysId":"c85cd2519f77230088aebde8132e70c2","table":"kb_knowledge","text":"Microsoft Outlook Issues This article explains how to use automatic replies in Outlook 2010 for Exchange accounts. Setting Up Automatic Replies Click the File tab. Click Automatic Replies. Select Send automatic replies. If desired, select the Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the Do not send automatic replies check box. On the Inside My Organization tab, ... ","title":"Microsoft Outlook Issues","columns":[{"fieldName":"sys_id","label":"sys_id","value":"c85cd2519f77230088aebde8132e70c2","displayValue":"c85cd2519f77230088aebde8132e70c2"},{"fieldName":"short_description","label":"Short description","value":"Microsoft Outlook Issues","displayValue":"Microsoft Outlook Issues"},{"fieldName":"sys_view_count","label":"View count","value":"0","displayValue":"0"},{"fieldName":"kb_knowledge_base","label":"Knowledge base","value":"a7e8a78bff0221009b20ffffffffff17","displayValue":"IT"},{"fieldName":"author","label":"Author","value":"6816f79cc0a8016401c5a33be04be441","displayValue":"System Administrator"},{"fieldName":"sys_updated_on","label":"Updated","value":"1550841174000","displayValue":"2 years ago"},{"fieldName":"kb_category","label":"Category","value":"1c1c6552ff0131009b20ffffffffff6c","displayValue":"Microsoft"}]}]},"resultsActionsMap":{"sys_attachment:cb0a8117db1a3410d74bb8e2f3961977":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:c85cd2519f77230088aebde8132e70c2":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:d15de43187032100deddb882a2e3ec7d":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:d7dc75b5474321009db4b5b08b9a7150":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:dcf43d75474321009db4b5b08b9a71dc":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:e31486b5474321009db4b5b08b9a7164":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:e97ee81eff6002009b20ffffffffffe0":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:f2765f9fc0a8011b0120ec1b352bf09b":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:f27d7f79c0a8011b0018f9d700d2b9aa":["40fdb34467fa1010b3d782f45685efe0"],"kb_knowledge:f40da43187032100deddb882a2e3ecc5":["40fdb34467fa1010b3d782f45685efe0"]},"availableActions":{"40fdb34467fa1010b3d782f45685efe0":{"sysId":"40fdb34467fa1010b3d782f45685efe0","actionId":"aisa_resolves","actionLabel":"Solves my issue","restPath":"/resolves","resultTable":null,"isCardAction":false,"isDetailAction":true,"searchApp":null,"scriptedVisibility":false,"visibilityScript":null,"resultTableCondition":null,"priority":0},"c6eefb4467fa1010b3d782f45685ef55":{"sysId":"c6eefb4467fa1010b3d782f45685ef55","actionId":"aisa_sc_cat_item_order","actionLabel":"Order","restPath":"/sc_cat_item_order","resultTable":"sc_cat_item","isCardAction":true,"isDetailAction":true,"searchApp":null,"scriptedVisibility":false,"visibilityScript":null,"resultTableCondition":"sys_class_name!=sc_cat_item_content^sys_class_name!=sc_cat_item_wizard^EQ"}}}}