40 views

Description

This article will show how to hide the "[view]' UI action link see within kb_knowledge articles and elsewhere within the platform.  This should really ONLY be used AFTER turning off the Document Viewer functionality.

NOTE: THIS IS A COMPLETELY UNSUPPORTED EXAMPLE SCRIPT AND IS PROVIDED AS IS.  PLEASE DO NOT CONTACT CUSTOMER SUPPORT FOR ASSISTANCE WITH THIS ARTICLE OR EXAMPLE.

Release or Environment

Modern releases in which the Document Viewer plugin has been installed.  Check for the plugin activation within the target environment:

Instructions

Go to: Plugins-->search for "Document Viewer" and confirm it's been installed.


Next, as this article is about HIDING the below-shown UI action link "[view]" shown below, we need to make sure that the Document Viewing functionality is disabled either globally (via a system property) or at a table level.  


See the following product documentation to DISABLE the Document Viewer:

https://docs.servicenow.com/bundle/paris-platform-user-interface/page/administer/form-administration/task/disable-doc-viewer.html


Here, we check the system property because we've turned off the feature globally.


There is no current OOB mechanism to allow for the easy modification or hiding of the Document Viewer "[view]" UI action link.

NOTE: THIS EXAMPLE UI SCRIPT IS NOT SUITABLE FOR RELATED LISTS AS SHOWN BELOW

The following script will allow for the hiding of the "[view]" link within kb_knowledge headers and elsewhere.

1. Create a new UI Script with UI Type as Desktop, and Global checked.
2. Enter the code as shown below (see screenshot for reference as well)


~~~snip~~~
(function(){
  
  if ( !document )
    return;
 
  var styles = [
    'li.attachment_list_items > span > a:nth-child(6) { display:none !important; }'
  ].join(' '),
  
  link = document.createElement( 'link' );
   
  link.type = 'text/css';
  link.rel = 'stylesheet';
  link.href = URL.createObjectURL( new Blob([ styles ], { type: 'text/css' }) );
  (document.head || document.documentElement).appendChild( link );
})();
~~~/snip~~~

3. Go to an existing kb_knowledge article that has an attached record and notice that the "[view]" UI action link is no longer displayed.

Please tailor this example to your own needs as required.

Additional Information

While mentioned several times above, it's worth saying again:

This example UI script is not supported or endorsed by ServiceNow.  Use this example script at your own risk.

Article Information

Last Updated:2020-10-26 10:09:29
Published:2020-10-26