Knowledge Base mod (kb_view.do)

Not applicable

I am trying to edit the kb_view.xml file to add an emailto: link in the body.
My first thought was to copy the file into UI Pages and then edit it from there.
This partially works as the new link will show up on the page, but the articles will not populate in the form.
I tried copying all of the kb_*.xml files into UI Pages as well with no success.

As a note If I replace the kb_view.xml directly on the server with my own copy it works fine with the new link and populating the article data.

Does anyone have any ideas how I can add kb_view.xml to UI Pages so it can be modified?

NOTE: there is a similar article dealing with the service catalog. http://wiki.service-now.com/index.php?title=Script:Catalog_Home_Remove_Search

I plan on adding the following lines to the table in the body of the article:



<tr><td align="right" bgcolor="#eeeeee"><span class="label">Email:</span></td><td><a href="mailto:?Subject=$[kb.short_description]&Body=You have been sent a knowledge article related to: <INSTANCE>?sysparm_article=$[kb.number]">Send to a Friend.</a></td>
</tr>


Below is the original kb_view.do



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
<link href="kb_styles.cssx" type="text/css" rel="stylesheet" />
<style type="text/css">
A {
color: blue;
text-decoration: underline;
}
TABLE {
white-space: normal;
}
IMG {
visibility: visible;
display: inline;
}
</style>

<g2:evaluate var="jvar_item" expression="
var kb = new GlideRecord('kb_knowledge');
kb.initialize();

if ('$[sysparm_article]' != '') {
kb.addQuery('number', '$[sysparm_article]');
kb.query();
if (!kb.next()) {
kb.number = '$[sysparm_article]';
kb.short_description = gs.getMessage('UNKNOWN ARTICLE');
} else if (!gs.hasRole(kb.roles) &amp;&amp; kb.roles != '') {
kb.initialize();
kb.number = '$[sysparm_article]';
kb.short_description = gs.getMessage('INSUFFICIENT ROLES TO VIEW PROTECTED ARTICLE');
}
} else {
kb.get('$[sys_id]');
}
gs.eventQueue('user.view', kb);
kb.incrementViewCount();
" />

<script>
function writeArticleURL() {
var baseArticleURL = location.href.substring(0, location.href.indexOf("?"));
document.write( baseArticleURL + "?sysparm_article=$[kb.number]");
}
</script>

<table class="wide" cellspacing="0" border="0" style="margin-bottom: 8px;">
<tr>
<td class="title" nowrap="true">
<g:inline template="kb_header.xml" />
</td>
</tr>
</table>

<table class="wide" cellspacing="0" border="0" style="margin-bottom: 8px;">
<tr><td>
<form method="GET" action="${sysparm_base_form}.do" name="${sysparm_base_form}.do">
<input type="HIDDEN" name="sys_submitted" id="sys_submitted" value="false" />
<input type="HIDDEN" name="sys_action" id="sys_action" value="none" />
<input type="HIDDEN" name="sys_id" id="sys_id" value="$[kb.sys_id]" />
<input type="HIDDEN" name="sysparm_modify_check" id="sysparm_modify_check" value="true" />
<g2:emitParms suppress="sysparm_this_url_enc"/>

<table class="wide" cellspacing="0">
<tr class="header"><td>
<table border="0" class="wide" cellspacing="0" cellpadding="0">
<tr class="header" border="0" cellspacing="0">
<td>
<input type="HIDDEN" id="sysverb_back" />
<img name="not_important"
value="sysverb_back"
id="sysverb_back"
onClick="return gsftSubmit(document.getElementById('sysverb_back'));"
src="images/green_back.gifx"
title="${gs.getMessage('Back')}"
alt="${gs.getMessage('Back')}"
class="noprint"
style="cursor:hand; margin-left: 4px;"/>
</td>
<td width="100%">
<div class="caption" style="margin-top: 2px;">
$[kb.number] > $[kb.short_description]
</div>
</td>
<j2:if test="$[sysparm_nameofstack != 'kbpop']">
<j2:if test="$[kb.canWrite()]">
<j2:if test="$[RP.isInteractive()]">
<td>
<button name="not_important" type="submit" value="sysverb_update" class="header" onClick="return kbEdit(this);">${gs.getMessage('kb.article.edit_button')}</button>
</td>
</j2:if>
</j2:if>
</j2:if>

<j2:if test="$[sysparm_nameofstack == 'kbpop']">
<td>
<g:evaluate var="jvar_search_fields" expression="gs.getProperty('glide.knowman.attach.fields');" />
<button name="not_important" value="sysverb_attach" class="header" onClick="return attachIncident(this, '${jvar_search_fields}');">${gs.getMessage('kb.article.attach_incident')}</button>
</td>
<g:solution_button/>
</j2:if>
</tr>
</table>
</td></tr>
<tr>
<td class="kb_text" valign="top">$[kb.text.getDisplayValue()]</td>
</tr>
<tr>
<td>
<br />
<hr />
</td>
</tr>
<tr>
<td >
<table>
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">$[kb.number.sys_meta.label]</span></td><td>$[kb.number]</td>
</tr>
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">$[kb.published.sys_meta.label]:</span></td><td>$[kb.published.getDisplayValue()]</td>
</tr>
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">$[kb.topic.sys_meta.label]:</span></td><td><a href="kb_list.do?jvar_view_topic=$[kb.topic]">$[kb.topic]</a></td>
</tr>
<j2:if test="$[kb.category != '']">
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">$[kb.category.sys_meta.label]:</span></td><td><a href="kb_list.do?jvar_view_topic=$[kb.topic]&jvar_view_category=$[kb.category]">$[kb.category]</a></td>
</tr>
</j2:if>
<j:set var="jvar_kb_showlinks" value="${gs.getProperty('glide.knowman.show_links','true')}" />
<j:if test="${jvar_kb_showlinks}">
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">Link:</span></td><td><script>writeArticleURL();</script></td>
</tr>
</j:if>
<j2:if test="$[kb.canWrite()]">
<tr>
<td align="right" bgcolor="#eeeeee"><span class="label">Views:</span></td><td>$[kb.sys_view_count]</td>
</tr>
</j2:if>
</table>
</td>
</tr>
</table>

<j2:if test="$[RP.isInteractive()]">
<g2:evaluate var="jvar_comments_label" expression="sys_meta.kb_feedback.comments.label" />

<table class="wide" style="margin-top: 5px;">
<tr><td><a onclick="toggleComments();"><img id="commentsimg" src="images/filter_hide.gifx"/>$[ gs.getMessage('kb.article.feedback.link') ]</a></td></tr>
<tr><td>
<div id="commentsdiv_done" style="display: none; background-color: #eeeeee; padding: 4px; border: 1px solid #dddddd;">
$[ gs.getMessage('kb.article.feedback.submitted') ]
</div>
<div id="commentsdiv" style="display: none; background-color: #eeeeee; padding: 4px; border: 1px solid #dddddd;">
<table class="wide" style="background-color: #eeeeee;">
<tr><td><span>$[jvar_comments_label]:</span></td></tr>
<tr><td><textarea name="article_comments" id="article_comments" style="width: 100%; height: 120px; margin-bottom: 5px;"></textarea></td></tr>
<tr><td><button name="not_important" type="submit" value="sysverb_feedback" onClick="return kbFeedback('article_comments');">$[ gs.getMessage('kb.article.feedback.submit_button') ]</button></td></tr>
</table>
</div>
</td></tr>
</table>
</j2:if>
</form>
</td></tr>
</table>
</j:jelly>

2 REPLIES 2

Not applicable

The problem is the link from kb_home and kb_find don't pass the correct sys_id to kb_view.

I got around this by creating kb_home and kb_find as UI Pages and adding a new parameter to the kb_view link. I called the parameter sysparm_viewer_id, to keep it the same as a link to the kb_view page with attachments.

..Nick


Not applicable


Nichs;4802


That is great. Would you be able to share a working example of your code?