- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2017 09:23 AM
Hi guys, please can someone let me know how it may be possible to edit what shows in the KB News widget?
I've observed that KB News articles currently show on it as long as Topic is 'News', it's published and within the 'Valid to' date however ideally we'd like to be able to e.g. set/customise the order the KB articles appear in? Or the font/size etc. Is there anyway to show more then the title of the KB article e.g. a byline/subheading?
Many thanks in advance,
DS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:22 AM
Hi there,
Problem:
It is NOT possible to edit what appears in the OOB News Gadget on dashboards. The OOB News Gadget will only show articles that are published with Topic=News. (The Topic field is an existing field that needs to be added to the form by right clicking on the form and going to form design, not sure why Topic is not visible OOB, but this is an easy fix.)
Solution:
However, it IS possible to create a new UI Page based on different criteria, and you can add a "new" gadget to the list of available gadgets on the dashboard using a new UI Page.
You will have to create a new UI page, and add to the existing "Gadgets" Widget
(also note that when you go to System UI > Widgets, you are actually viewing Widget Categories, the widgets themselves are built into the code of the widget category)
First step here is to update the existing widget (or if you so choose, create a new one):
Widget Name: Gadgets
Here is the code for the widget, I have commented where the changes should be made.
function sections() {
return {
'Sticky Note' : { 'type' : 'sticky', 'content' : 'Default sticky note text here.' },
'News' : { 'type' : 'news' },
// below is a sample line to add a new item under Category=Gadgets when adding to homepage/dashboard
// 'NEW GROUP NAME' : { 'type' : 'new_group_type'},
'System Information' : {
'Overview' : { 'type' : 'system', 'action' : 'overview' },
'Last Upgrade' : { 'type' : 'system', 'action' : 'upgrade_history' }
},
'Priority 1 Incidents' : { 'type' : 'priority_incidents' },
'Priority 1 Problems' : { 'type' : 'priority_problems' },
'Emergency Changes' : { 'type' : 'emergency_changes' },
'Knowledge Search' : { 'type' : 'knowledge_search' }
};
}
function render() {
var type = renderer.getPreferences().get("type");
var gf = new GlideForm(renderer.getGC(), "render_gadget_" + type, 0);
gf.setDirect(true);
gf.setRenderProperties(renderer.getRenderProperties());
return gf.getRenderedPage();
}
function getEditLink() {
if (!gs.hasRole('admin'))
return '';
if (renderer.getPreferences().get('type') == 'news')
return 'kb_knowledge_list.do?sysparm_query=topic=News';
// you can add additional 'if' statements, or modify the above 'if' statement if you want to sort by anything other than topic=News
return "sys_ui_page.do?sysparm_query=name=render_gadget_" + renderer.getPreferences().get("type");
}
Here is the code for the UI Page
(IMPORTANT NOTE: the name of the UI Page must use the standard convention of "renderer_gadget_NEW_GROUP_TYPE" , where "NEW_GROUP_TYPE" = the new code you added to the widget under function Sections.)
UIPage Name: renderer_gadget_NEW_GROUP_TYPE
Here is the code for the widget, please see my comments for where you should add your query.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_inc">
var kb = new GlideRecord('kb_knowledge');
kb.addActiveQuery();
kb.addEncodedQuery("ADD_QUERY_HERE");
// sample query is kb_knowledge_base=1f283b70db60a700f4def35aaf961956, you can use any variable on the knowledge table to filter here, my sample uses kb_knowledge_base
kb.query();
</g2:evaluate>
<g2:scrollable_area height="100px">
<table border="0" cellspacing="2" cellpadding="2" width="100%">
<j2:while test="$[kb.next()]">
<j2:set var="jvar_inc_link" value="kb_view_customer.do?sys_kb_id=$[kb.sys_id]"/>
<tr>
<td>
<a class="kb_link" href="$[jvar_inc_link]"><img src="images/nav_bult.gifx"/></a>
<a href="$[jvar_inc_link]" class="kb_link"> <b> $[kb.short_description] </b> </a>
</td>
<td align="right" valign="top" nowrap="true">
<span style="padding-right:4px;"><i>$[kb.published]</i></span>
</td>
</tr>
</j2:while>
</table>
</g2:scrollable_area>
</j:jelly>
Once you do this, you should be able to go to any homepage/dashboard, click "Add Content" and when you click on "Gadgets" in the left-most column, a new section in the middle that you just created should appear.
A few things to keep in mind:
Changing just the widget code will not suffice because it is actually the UI Page that is displaying the results you want that you need. If you change the widget code and not the ui page, you will see the new widget under "Add Content", however nothing will scroll in the news filter (if you click the edit icon for this widget, you should still see the correct records, however without adding the UIPage, the news Gadget will not scroll the relevant records.)
The easiest way (without changing any code) is to simply make the "Topic" field visible on the Knowledge Article forms, and whenever you want an Article to show, simply Publish the article, and ensure the Topic=News. If you add the "Topic" field to the form, it will make this much easier to manage.
Only the Short Description of the Article (with creation date) will scroll on the News Gadget. However the articles should be clickable.
When you click the "Edit" button on the News Ticket, it should take you to the list of relevant records, however if it, instead, directs you to the ui_page configuration screen, you need to go back to your Widget and add an "if" statement to the code under the function getEditLink.
Here are a few sites that helped me come to these conclusions (like to give credit where it's due):
https://express.servicenow.com/support/create-announcements-news-gadget-knowledge/
https://docs.servicenow.com/bundle/helsinki-platform-user-interface/page/administer/homepage-administration/task/t_CreateAWidgetReferencingUIPage.html
https://docs.servicenow.com/bundle/kingston-platform-user-interface/page/use/dashboards/task/create_widget_displays_webpage.html
https://community.servicenow.com/community?id=community_question&sys_id=a09d0b2ddb9cdbc01dcaf3231f9619b6
https://www.servicenowguru.com/system-ui/creating-knowledge-search-homepage-widget/
Big Shout out to the all-star we all know and love, Chuck Tomasi for leading the way on to this solution...
Hope this helps, please mark helpful and correct, if so.
Dan R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2017 09:30 AM
Btw may be using wrong terminology in that I think it's technically a gadget right?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:22 AM
Hi there,
Problem:
It is NOT possible to edit what appears in the OOB News Gadget on dashboards. The OOB News Gadget will only show articles that are published with Topic=News. (The Topic field is an existing field that needs to be added to the form by right clicking on the form and going to form design, not sure why Topic is not visible OOB, but this is an easy fix.)
Solution:
However, it IS possible to create a new UI Page based on different criteria, and you can add a "new" gadget to the list of available gadgets on the dashboard using a new UI Page.
You will have to create a new UI page, and add to the existing "Gadgets" Widget
(also note that when you go to System UI > Widgets, you are actually viewing Widget Categories, the widgets themselves are built into the code of the widget category)
First step here is to update the existing widget (or if you so choose, create a new one):
Widget Name: Gadgets
Here is the code for the widget, I have commented where the changes should be made.
function sections() {
return {
'Sticky Note' : { 'type' : 'sticky', 'content' : 'Default sticky note text here.' },
'News' : { 'type' : 'news' },
// below is a sample line to add a new item under Category=Gadgets when adding to homepage/dashboard
// 'NEW GROUP NAME' : { 'type' : 'new_group_type'},
'System Information' : {
'Overview' : { 'type' : 'system', 'action' : 'overview' },
'Last Upgrade' : { 'type' : 'system', 'action' : 'upgrade_history' }
},
'Priority 1 Incidents' : { 'type' : 'priority_incidents' },
'Priority 1 Problems' : { 'type' : 'priority_problems' },
'Emergency Changes' : { 'type' : 'emergency_changes' },
'Knowledge Search' : { 'type' : 'knowledge_search' }
};
}
function render() {
var type = renderer.getPreferences().get("type");
var gf = new GlideForm(renderer.getGC(), "render_gadget_" + type, 0);
gf.setDirect(true);
gf.setRenderProperties(renderer.getRenderProperties());
return gf.getRenderedPage();
}
function getEditLink() {
if (!gs.hasRole('admin'))
return '';
if (renderer.getPreferences().get('type') == 'news')
return 'kb_knowledge_list.do?sysparm_query=topic=News';
// you can add additional 'if' statements, or modify the above 'if' statement if you want to sort by anything other than topic=News
return "sys_ui_page.do?sysparm_query=name=render_gadget_" + renderer.getPreferences().get("type");
}
Here is the code for the UI Page
(IMPORTANT NOTE: the name of the UI Page must use the standard convention of "renderer_gadget_NEW_GROUP_TYPE" , where "NEW_GROUP_TYPE" = the new code you added to the widget under function Sections.)
UIPage Name: renderer_gadget_NEW_GROUP_TYPE
Here is the code for the widget, please see my comments for where you should add your query.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_inc">
var kb = new GlideRecord('kb_knowledge');
kb.addActiveQuery();
kb.addEncodedQuery("ADD_QUERY_HERE");
// sample query is kb_knowledge_base=1f283b70db60a700f4def35aaf961956, you can use any variable on the knowledge table to filter here, my sample uses kb_knowledge_base
kb.query();
</g2:evaluate>
<g2:scrollable_area height="100px">
<table border="0" cellspacing="2" cellpadding="2" width="100%">
<j2:while test="$[kb.next()]">
<j2:set var="jvar_inc_link" value="kb_view_customer.do?sys_kb_id=$[kb.sys_id]"/>
<tr>
<td>
<a class="kb_link" href="$[jvar_inc_link]"><img src="images/nav_bult.gifx"/></a>
<a href="$[jvar_inc_link]" class="kb_link"> <b> $[kb.short_description] </b> </a>
</td>
<td align="right" valign="top" nowrap="true">
<span style="padding-right:4px;"><i>$[kb.published]</i></span>
</td>
</tr>
</j2:while>
</table>
</g2:scrollable_area>
</j:jelly>
Once you do this, you should be able to go to any homepage/dashboard, click "Add Content" and when you click on "Gadgets" in the left-most column, a new section in the middle that you just created should appear.
A few things to keep in mind:
Changing just the widget code will not suffice because it is actually the UI Page that is displaying the results you want that you need. If you change the widget code and not the ui page, you will see the new widget under "Add Content", however nothing will scroll in the news filter (if you click the edit icon for this widget, you should still see the correct records, however without adding the UIPage, the news Gadget will not scroll the relevant records.)
The easiest way (without changing any code) is to simply make the "Topic" field visible on the Knowledge Article forms, and whenever you want an Article to show, simply Publish the article, and ensure the Topic=News. If you add the "Topic" field to the form, it will make this much easier to manage.
Only the Short Description of the Article (with creation date) will scroll on the News Gadget. However the articles should be clickable.
When you click the "Edit" button on the News Ticket, it should take you to the list of relevant records, however if it, instead, directs you to the ui_page configuration screen, you need to go back to your Widget and add an "if" statement to the code under the function getEditLink.
Here are a few sites that helped me come to these conclusions (like to give credit where it's due):
https://express.servicenow.com/support/create-announcements-news-gadget-knowledge/
https://docs.servicenow.com/bundle/helsinki-platform-user-interface/page/administer/homepage-administration/task/t_CreateAWidgetReferencingUIPage.html
https://docs.servicenow.com/bundle/kingston-platform-user-interface/page/use/dashboards/task/create_widget_displays_webpage.html
https://community.servicenow.com/community?id=community_question&sys_id=a09d0b2ddb9cdbc01dcaf3231f9619b6
https://www.servicenowguru.com/system-ui/creating-knowledge-search-homepage-widget/
Big Shout out to the all-star we all know and love, Chuck Tomasi for leading the way on to this solution...
Hope this helps, please mark helpful and correct, if so.
Dan R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2018 02:49 AM
Many thanks for taking the time to reply with such a detailed response. Much appreciated.