- 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-13-2024 07:28 AM
Try setting the client script to run "onLoad".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-14-2024 06:57 AM
That's how it was set from the beginning. And it does seem to load on KB edit pages. Above, it was suggested that's the wrong "table". What's the table for "KB view"?
- 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.