{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":39610,"path":"platform-administration/search-suggestions/view-ext-user-search-suggestions.md","title":"Use the GraphQL REST API to view suggestions created from external user searches","bundle":null,"doc_type":null,"release":"australia","body":"\n# Use the GraphQL REST API to view suggestions created from external user searches\n\nSubmit a request to the GraphQL REST API endpoint to retrieve search suggestions created from searches by self-registered external users. This endpoint allows access by non-authenticated guest users.\n\n## Before you begin\n\nEnsure that the following conditions are met in your instance:\n\n-   The Domain Separation plugin isn't activated. For details on this plugin, see [Domain separation plugin](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/domain-sep-plugin.md).\n-   The Explicit Roles plugin \\(com.glide.explicit\\_roles\\) is activated. To learn more about this plugin, see [Explicit Roles](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/explicit-roles.md).\n-   External users with the snc\\_external role have submitted searches in search applications that generate search suggestions, such as ServiceNow® Service Portal, Now Mobile, or ServiceNow® Virtual Agent.\n-   The **glide.search.suggestions.allow\\_guest\\_user** system property is set to **true**. For details on setting a system property value, see [Add a system property](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/t_AddAPropertyUsingSysPropsList.md).\n\nObtain the sys\\_id of the search application that you want to retrieve external user search suggestions for.\n\n**Note:** Users with the search\\_application\\_admin, agent\\_workspace\\_user, or workspace\\_user roles can obtain this sys\\_id by copying it from the search application record in the Search Application Configuration \\[sys\\_search\\_context\\_config\\] table.\n\nDownload a third-party GraphQL client, such as the GraphiQL, Insomnia, or Postman client.\n\nRole required: none\n\n## About this task\n\nSearch Suggestions creates suggestions for searches performed by self-registered external users. When the **glide.search.suggestions.allow\\_guest\\_user** system property is set to **true**, non-authenticated guest users can access the GraphQL REST API endpoint for your instance to retrieve external user search suggestions for a search application.\n\nNo authentication is required or enforced for this GraphQL REST API endpoint.\n\n**Note:** Non-authenticated guest users can only retrieve search suggestions from the Global domain. If domain separation is enabled in your instance, guest users can't retrieve any search suggestions.\n\n## Procedure\n\n1.  In your third-party GraphQL client, configure a new request that uses the HTTP POST method.\n\n2.  Set the endpoint for the request to the GraphQL REST API endpoint for your instance, `https://<instance name>.service-now.com/api/now/graphql`.\n\n3.  Set the request body to the following GraphQL query, replacing `<search_application_sys_id>` with the sys\\_id of the search application that you want to retrieve external user search suggestions for:\n\n    ```\n    {\n      GlideSearch_Query {\n        suggestions(searchContextConfigId: \"<search_application_sys_id>\", searchTerm: \"\") {\n          term\n          data {\n            name\n            records {\n              type\n              columns {\n                label\n                fieldName\n                value\n                displayValue\n              }\n            }\n          }\n        }\n      }\n    }\n    ```\n\n\n## Result\n\nThe system returns search suggestions from application searches by self-registered external users as a JSON object, as shown in this example:\n\n```\n{\n  \"data\": {\n    \"GlideSearch_Query\": {\n      \"suggestions\": {\n        \"term\": \"\",\n        \"data\": [\n          {\n            \"records\": [\n              {\n                \"type\": \"POPULAR_QUERY\",\n                \"columns\": [\n                  {\n                    \"label\": \"name\",\n                    \"displayValue\": \"automatic replies\",\n                    \"value\": \"automatic replies\",\n                    \"fieldName\": \"name\"\n                  }\n                ]\n              },\n              {\n                \"type\": \"POPULAR_QUERY\",\n                \"columns\": [\n                  {\n                    \"label\": \"name\",\n                    \"displayValue\": \"contact group\",\n                    \"value\": \"contact group\",\n                    \"fieldName\": \"name\"\n                  }\n                ]\n              },\n              {\n                \"type\": \"POPULAR_QUERY\",\n                \"columns\": [\n                  {\n                    \"label\": \"name\",\n                    \"displayValue\": \"tablet\",\n                    \"value\": \"tablet\",\n                    \"fieldName\": \"name\"\n                  }\n                ]\n              },\n              {\n                \"type\": \"POPULAR_QUERY\",\n                \"columns\": [\n                  {\n                    \"label\": \"name\",\n                    \"displayValue\": \"laptop\",\n                    \"value\": \"laptop\",\n                    \"fieldName\": \"name\"\n                  }\n                ]\n              },\n              {\n                \"type\": \"POPULAR_QUERY\",\n                \"columns\": [\n                  {\n                    \"label\": \"name\",\n                    \"displayValue\": \"new email account\",\n                    \"value\": \"new email account\",\n                    \"fieldName\": \"name\"\n                  }\n                ]\n              }\n            ],\n            \"name\": \"Popular searches\"\n          }\n        ]\n      }\n    }\n  }\n}\n```\n\n"}}