How do I improve the contextual search results email notification?

Kevin Upshaw
Kilo Contributor

How do I improve the contextual search results email notification?

Keen to see if anyone has improved the out-of-box email notification for contextual search results (cxs_EmailSearchResults).  

Only documentation I can find - https://docs.servicenow.com/bundle/tokyo-platform-administration/page/administer/contextual-search/task/t_ConfigureAnEmailNotification.html 

Problems:

  1. It doesn't inherit any CSS from the notification template itself.  There is no technical documentation on how to style the email script.  Has anyone improved the look feel (current - Screenshot 1, example of how it could look good - Screenshot 2).  
  2. Can we limit only sending a "self-service recommendations" email notification if there are results returned by the contextual search results producer?  i.e. if no search results returned (no KB articles, no service catalog items) - then no email notification is sent.  

Copy of the out-of-box email script:

(function() {
    var searchRequest = cxs_App.getActions("cxs_TableActions", current).getEmailSearchRequest(email_action);
    if (!searchRequest || searchRequest == null || !searchRequest.query.freetext || !searchRequest.meta.get("runAsUser"))
        return;

    var imp = new GlideImpersonate();
    var previousUserId = imp.impersonate(searchRequest.meta.get("runAsUser"));
    var searchResponse = SNC.SearchService.search(searchRequest);
    var searchResponseObj = new JSON().decode(searchResponse.toJSON());
    
    template.print(cxs_App.getActions("cxs_FormatResults", searchResponseObj).usingMacro({
        "result_header_macro": "cxs_results_header_email",
        "result_macro": "cxs_result_email"
    }));

    if (previousUserId)
        imp.impersonate(previousUserId);
})()
0 REPLIES 0