How to create custom UI actions on the KB article view page?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Community,
I'm currently working on customizing the Knowledge Base in ServiceNow and had a question regarding UI Actions on the Knowledge Article view page.
Requirement:
I want to create a custom UI Action (button) that appears on the Knowledge Article view page (kb_view / Knowledge Portal view), and perform a specific action when clicked.
Any guidance, examples, or documentation links would be greatly appreciated.
Thanks in advance!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
59m ago
Customize the UI Macro
- Navigate to System UI → UI Pages → kb_view. Open the Jelly source and look for
<g:call>or<g:include>tags — these reference the UI Macros that render the button bar (commonly something likekb_view_article_actions). - Clone that UI Macro (never edit OOB directly). In your cloned macro, add your button:
xml
<j:if test="${gs.hasRole('your_required_role')}">
<button class="btn btn-default" onclick="yourCustomAction('${jvar_article_sys_id}')">
Your Button
</button>
</j:if>
- Update the
kb_viewUI Page to reference your cloned macro instead of the original. - Add your server-side logic via a Script Include, and call it from the button using GlideAjax:
javascript
function yourCustomAction(sysId) {
var ga = new GlideAjax('YourScriptInclude');
ga.addParam('sysparm_name', 'yourMethod');
ga.addParam('sysparm_article_id', sysId);
ga.getXMLAnswer(function(response) {
alert('Done: ' + response);
});
}
