- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 06:49 AM
I figured out why my script wasn't running - it was, but ONLY when someone is editing a KB article - not when they view it. I'm trying to write a script for the viewers of the KB, not it's editors. How can I make that happen?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 07:37 AM
Hi @jeremyduffy
Viewing KB articles won't run the client scripts set on the KB "edit" pages. The "edit" pages as you put it are the configuration pages; the front-end for adding data to the database, in this case data for KB articles.
KB articles really are constructed in a way where it's really an article; text to read. So there isn't a direct way to make it interactive or things to happen by script.
Like @CezaryBasta posted kb articles are viewed via a portal page (service portal widget) or a UI page (pages on the native UI side). KB articles aren't like record producers/catalog items where catalog client scripts or UI policies can be leveraged to make some interactivity.
In order to make KB articles have interactivity:
Via Service Portal
- Clone the KB View or KB View2 widget and add scripting there replacing the out of box widget
- Or create a wrapper widget and embed KB View or KB View 2 widget and replace the out of box widget
- Or create a custom widget with just the necessary scripting and place it on the same page as the out of box widget
Via native side UI page
- Edit the kb_view UI Page and add the necessary scripting
- Note that modifying this page you will lose any updates that ServiceNow may create because this is an out-of-box page and once modified the owner becomes the customer.
Hopefully that helps explain or sheds more light on the situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 06:51 AM
How is the article viewed?
- If it's on the portal, you'd have to modify the widget responsible for displaying it
- If it's on the backend (which I doubt, but it's still an option), you'd have to modify the UI Page responsible for displaying it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 06:57 AM
I'm not doing anything fancy - they're just clicking "knowledge base" and then my article. So let's assume "portal". Is it just a matter of finding the right "portal" table to target then? Is there a service now default "portal kb" table I would use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 06:54 AM
No, it's not about targeting the table at all. If it's on the portal, you'd ahve to update the widget responsible for displaying the article and include your code there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 07:45 AM
So a client script won't work at all?