Document Management - Search and Access Documents from Employee Center Portal

ChadO
Giga Expert

 

Hello everyone.  We are exploring the Document Management application and have installed it and set it up, including integrating it with our Google Drive environment.  What we are looking to do next is to get things set up such that users can search for Document Management documents in our Employee Center Pro portal and access them via the search results, assuming they have access to the document.  Is there an out-of-the-box way to get things set up so that our documents are included in and accessible via the portal search results?  Thanks!

1 ACCEPTED SOLUTION

ChadO
Giga Expert

We got the EC Portal Document searching to work in our instances.  Here's what we had to do to achieve that:

  • Create a new AI Search Indexed Source (ais_datasource) record for the Document (ds_document) table.
    • In the "Field Settings & Mappings" related list include at least one entry with: Source = ds_document, Value = title, Attribute = map_to, and Field = <Whatever field from the ds_document table that you want to be the title of the search result.  I used the name field.>
    • I also created an "Advanced Configuration" related list entry for: Source = ds_document, Attribute = index_attachments, Value = true
    • After creating the Indexed Source and the various related list items click on the "Index All Tables" button to run the index for the table.
  • Create a new AI Search Source (ais_search_source) record that references the Indexed Source from bullet 1 above.
  • Open the AI Search Application Configuration (sys_search_context_config) that is used by your active portal(s) and then navigate to the Search Profile (ais_search_profile) referenced by that record.  On the Search Profile record there is a related list for "Search Sources".  Add the Search Source created in bullet 2 above to that list using the "Link Existing" related list button.

Doing the above got us to the point where when we searched on our EC portal for the documents they would show up in a new "Documents" search tab on the search results page.  Note that before we created the "map_to" attribute for title we would see a number in parentheses next to "Documents" but clicking on that tab would show an empty list.  Once we did the map_to attributes for title (and then later text) we started seeing results that we could click on.  That said, by default clicking on the results brought us to the document record form view within the portal, which we didn't want.  We instead wanted a page showing basic things about the document, such as the name, version, and description, and then a link to the attachment associated with the latest published Document Version (ds_document_version).  To do that we had to do the following:

  • Created a custom service portal widget.  The details of ours is below but you can obviously make this to be whatever you want to show, style, etc.
    Body HTML template:
<div ng-if="data.isvalid">

  <div class="panel b">

    <div class="panel-heading">
        <h2 class="panel-title h4" style="overflow:hidden">
            <span class="pull-left">{{::data.title}}</span>
        </h2>
      	<h5 class="h5" style="overflow:hidden">
            <span class="pull-left">${Version} {{::data.version}}</span>
        </h5>
    </div>

    <div class="panel-body m-b-lg wrapper-lg">

      <div ng-if="data.description" class="doc_description" style="overflow-x:auto;"><span>{{::data.description}}</span></div>

      <div ng-if="::data.showAttachments" class="b-t m-t">
        <h5>
          ${View or download the attachments below}
        </h5>
        <sp-attachment-manager table="::data.table" sys-id="::data.sys_id" omit-edit="true"></sp-attachment-manager>
      </div>
      
      <div ng-if="::!data.showAttachments" class="b-t m-t">
        <h5>
          ${No attachments available}
        </h5>
      </div>

    </div>
  </div>
</div>

<div ng-if="!data.isvalid">
  ${Document not found}
</div>​

Server script:

(function() {
	data.isvalid = false;
	
	var docGr = new GlideRecord("ds_document");
	var id = $sp.getParameter("sys_id") || $sp.getParameter("sys_doc_id");
	docGr.addQuery("sys_id", id);
	docGr.query();
	if (!docGr.next())
		return;
	
	if (!docGr.canRead())
		return;
	
	data.isvalid = true;
	data.title = docGr.name.toString();
	data.description = docGr.description.toString();
	data.showAttachments = false;
	
	// Get latest document version
	var docVersion = new GlideRecord("ds_document_version");
	docVersion.addQuery("document", docGr.sys_id.toString());
	docVersion.addQuery("version_state", "published");
	docVersion.setLimit(1);
	docVersion.query();
	if (docVersion.next()) {
		data.version = docVersion.version.toString();

		// Check for attachments
		var attachments = new GlideRecord("sys_attachment");
		attachments.addQuery("table_name", "ds_document_version");
		attachments.addQuery("table_sys_id", docVersion.sys_id.toString());
		attachments.setLimit(1);
		attachments.query();
		if (attachments.hasNext()) {
			data.showAttachments = true;
			data.table = "ds_document_version";
			data.sys_id = docVersion.sys_id.toString();
		}
	}

	// Breadcrumbs
	data.breadcrumbs = [{label: data.title, url: '#'}];
})();

Client controller:

function ($scope, spUtil, $sce, $rootScope, $timeout, $location) {
	$timeout(function() {
		$rootScope.$broadcast('sp.update.breadcrumbs', $scope.data.breadcrumbs);
	});
}
  • Create a custom Service Portal page that uses the widget above.
  • Create an AI Search Results Action Configuration (sp_ai_search_results_action_config) record.  Here specify the AI Search Source to be the one created in bullet 2 of the first set of bullets, the Portal page to be the one created in bullet 2 immediately above, Action name = navigation, and for our specific widget I added a "Payload query parameters" entry of for field = sysId, value = sys_doc_id.  Make sure it's active and if you want to specify the Service Portal(s) that this action configuration will work with you can do so using the "Service Portal(s)" field.  Leaving the "Service Portal(s)" field empty makes the action configuration usable by all portals.
  • Create a new EVAM View Template (sys_ux_composite_data_template) where Name = <any name>, Active = true, and Template = 
{
    "component": "sn-search-result-evam-card",
    "staticValues": {},
    "mappings": {
        "title": "ai_search_teaser_title",
        "summary": "ai_search_teaser_text",
        "ariaLabel": "ai_search_teaser_title"
    },
    "actionMappings": {
        "clickAction": "navigation"
    }
}​
  • Navigate back to the portal record(s) for the active portal(s) you are using and open the referenced "Search Results Configuration" EVAM Definition (sys_ux_composite_data) record(s).  Go to the "EVAM View Config Bundle M2Ms" related list, pick any of the View Config Bundles, and open the record.  I picked "ESC Portal Search Bundle" associated with our EVAM Definition since it seemed most appropriate.
  • On the EVAM View Config Bundle record (sys_ux_composite_data_template_predicate_bundle) there is an "EVAM View Configs" related list.  Click New on that related list to create a new EVAM View Config record.
  • Create the new EVAM View Config (sys_ux_composite_data_template_predicate) where: Name = <any name>, Table = ds_document, View Template = <the EVAM View Template created in bullet 4 above>, Table Fields = Name, Description, Owner, Department, Type, Classification, State, Custom Fields = ai_search_teaser_title,ai_search_teaser_text, Active = true
    1. Note for the Table Fields you can select or exclude different fields but that's what we chose.
  • Go back to the EVAM View Config created in bullet 7 immediately above and in the "EVAM View Config Action Assignment M2Ms" related list use the "Link Existing" button to link the "navigation" Declarative Action.

With all of that done you should ultimately have the EVAM Definition referenced by your portal(s) linked to an EVAM View Config Bundle that contains an EVAM View Config for the ds_document table.

 

Once all of that is complete, clicking on a Documents search result should take you to the custom poratl page specified in the AI Search Results Action Configuration that you created instead of the ds_document form view.

 

Hope all this helps.

 

Chad

View solution in original post

7 REPLIES 7

rachelsilveira
Tera Contributor

We are also very interested in hearing about your implementation of the Document Management application.  Would you be willing to share your journey so far?  We are looking at a current need to have documents searchable in EC Pro.  Thanks! 

Our implementation is still very early days.  We have the out-of-the-box Document Management plugin along with the multi-provider applications in order to integrate with GDrive.  We are able to create documents either in SNOW or GDrive and have them sync back and forth.  Versioning also works great we just can't figure out the EC Pro piece.  If we get the integration with EC Pro figured out either via a response here or via a ServiceNow Support Case I'll for sure let you know.

This is very helpful.  Yes, Please I would love to hear more.  I have subscribed to your post, fingers crossed you get a solution here!

LaurenG
Tera Contributor

Hi @ChadO,

 

You can use the Knowledge Document plug-in to make documents held in Managed Documents searchable in Employee Center. This plugin gives you the ability to link a document to a Knowledge Article and it is the Knowledge Article with the document attachment that will appear in the search. 

 

Product Documentation: Knowledge Document plugin

 

If you feel this was helpful, please consider giving thumbs up and if it solved your issue, please mark this correct.
Many thanks