ServiceNow keeps track of the views for each Knowledge Base (kb_knowledge) article by updating the View Count (sys_view_count) field on the article's record each time it is viewed. However this update is done such that no other fields are updated on the record (including system fields such as the sys_updated_on field) and as a result does not trigger business rules or flows (including those created by dynamic shares) to fire.

However since article views fire a kb.view event each time an article is viewed, we can create a ServiceNow Script Action that is triggered when this event happens. This will allow you to dynamically share out Knowledge Base articles when the view count is changed. 

(info) NOTE: This is an advanced configuration, and is NOT part of standard functionality. Perspectium Support can assist you if any issues occurs with the configuration. 



Procedures

To start sharing knowledge articles through a script action, follow this procedure: 


Navigate to Dynamic Share

In ServiceNow's left side navigation window, navigate to Perspectium > Replicator > Dynamic Share or simply type and then click on Dynamic Share

Click New

Choose Dynamic Share Type

Select Business Rule and click the Submit button.

Create a Dynamic Share 

Select Knowledge in the Table dropdown, and check the Active box. 

Under the Trigger Conditions tab, check the Update box. Then, follow the rest of the steps in Create a ServiceNow dynamic share

Navigate to Script Actions 

In ServiceNow's left side navigation window, navigate to System Policy > Events > Script Actions. Then, click New

Create Script Action

In the Name field, type in Perspectium Share Knowledge. Select kb.view as the Event name, and check the Active box. 

Then, fill in the Script field with the following: 

pspShareKnowledge();

function pspShareKnowledge() {
	var pspR = new PerspectiumReplicator();
	var tableName = "kb_knowledge";
	
	var kbgr = new GlideRecord(tableName); 
	kbgr.get('sys_id', event.instance);
	kbgr.query();
	if (!kbgr.next())
		return; 
	
	var qc = new GlideRecord('psp_replicate_conf');
	qc.addQuery("table_name", tableName);
	qc.addQuery("sync_direction", "share");
	qc.addQuery("action_update", "true");
	qc.addQuery("active", "true");
	qc.query();
	while(qc.next()) {
		pspR.shareRecord(kbgr, tableName, 'bulk', qc.sys_id);	
	}
}

Click Submit