- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 12:54 PM
Hello team!
I have a requirement on the incident module, they created a field where you can select a knowledge article to relate it to the incident, but they discovered that when trying to access the article with the button from the i icon it would take you to the edit article view, so the requirement is to have something that could take you directly to the end user view of the article and not to the part where you edit it.
So to make it nice and simple I was thinking of creating a UI macro that called the OOTB kb_view UI page, for that knowledge article, I have done it using GlideDialogWindow, but I can't seem to find a way to open the specific article within the UI page, and all I get is a "knowledge record not found" error message when clicking the UI Macro icon. I'm guessing my problem is on how to pass the knowledge article sys_id to the ui page.
Any kind of advice is appreciated.
The code for the UI Macro is below
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_art_preview_${jvar_guid}:${ref}"/>
<a id="${jvar_n}" onclick="sendToNorChange('${ref}')">
<img border="0" src="book-icon.png" width="30" height="30" title="${gs.getMessage('Show Preview')}" alt="${gs.getMessage('Show Preview')}"/>
</a>
<script>
//OnClick function for UI macro
function sendToNorChange(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField); //article sys_id
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var kbarti = 'kb_view.do?sys_kb_id='+ v;
<!-- alert(kbarti); d.setSysID(v);-->
var d = new dialogClass('kb_view');
d.setTitle('${JS:gs.getMessage("Show Preview")}');
d.setPreference('sys_id',v);
d.render();
}
</script>
</j:jelly>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 05:15 PM
Hi
Try replacing your Client Script with this
<script>
//OnClick function for UI macro
function sendToNorChange(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
if(v){
window.open("/kb_view.do?sys_kb_id=" + v);
}else{
g_form.showFieldMsg(referenceField, 'Please select an article first.', 'error');
}
}
</script>
It will open KB Article in new tab.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 02:12 PM
Hi
Are you getting something like this
If so, then try replacing
d.setPreference('sys_id',v);
With
d.setPreference('sys_kb_id',v);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 05:15 PM
Hi
Try replacing your Client Script with this
<script>
//OnClick function for UI macro
function sendToNorChange(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
if(v){
window.open("/kb_view.do?sys_kb_id=" + v);
}else{
g_form.showFieldMsg(referenceField, 'Please select an article first.', 'error');
}
}
</script>
It will open KB Article in new tab.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:02 AM
Thank you Muhammad!, it did work perfectly.