Displaying specific topics/categories to users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 02:45 PM
We are looking to display specific topics/categories in the pull down list of the knowledge home page to users based on an a setting in the audience field of the knowledge form and user type in the user record. Currently we filter articles using ACL's with the combination of the audience field and user type field but we cannot control what selection of topics/categories is available for selection
- Labels:
-
Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2014 11:36 AM
Thanks everyone, this helps as I have a few options to try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2014 02:34 PM
Slava, I'm trying your approach. Referring to your statement var topics = $$("table.kb_main div[dragpart=Applications]"); what table are you referring to? Your example is for one topic which is hard coded. I'm trying to separate Agent and Employee therefore it looks like I will need a table that defines topics that belong to an Agent and topics that belong to employee's. Can you give me a few more details on what you mean by which table in the statement you are referring to? If I need to use an alternate table that defines who should see the topics, can you help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2014 01:01 AM
In this context, the word "table" does not refer to a database table. What we are actually doing here is manipulating the HTML DOM (Document Object Model) of the page.
Each block on KB home page is a <div> with the name of the topic/category in the dragpart attribute. Expression inside the brackets is a CSS selector that simply finds a <div> with the relevant value of the dragpart attribute inside a <table> tag that has class = "kb_main".
Instead of hard-coding the name of the topic that needs to be hidden, you can add some code in the beginning to determine it based on attributes of the user or anything else and then pass it to your function as a parameter.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2014 02:03 AM
Here is a very rough draft of the UI script. You will need to use GlideAjax to make a call to a script include where you can define all your logic for hiding topic/categories.
addLoadEvent(function() {
if(location.href.indexOf('/kb_home.do') != -1 && location.href.indexOf('jvar_view_topic') == -1) {
// Use GlideAjax here to make a call to a script include
// that will determine which topics need to be hidden...
//
// http://wiki.servicenow.com/index.php?title=GlideAjax
var ga = new GlideAjax('GetTopics');
ga.addParam(...);
ga.addParam(...);
ga.getXML(MyCallBackFunc);
function MyCallBackFunc(response) {
myTopic = 'name_of_the_topic';
hideTopic(myTopic);
}
}
});
function hideTopic(t) {
var topics = $$("table.kb_main div[dragpart=" + t + "]");
if(topics.length > 0)
topics[0].hide();
}
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/