Home Cireson Uploads
image


IT Monkey will place code here as examples of what Cireson's consulting team has to offer as well as examples for public consumption to benefit the Microsoft System Center community as a whole.

DISCLAIMER

All files and projects located here come as is and without any warranty or support. We will attempt to improve the projects as time goes on based on customer and community demand. Comments and improvements are welcome as well as customization requests. Your use of these Cireson Uploads is subject to our Terms of Use.


Cireson's support team has no information on these projects outside of what you have available and will not provide support for these enhancements, extensions, and scripts.

Dont forget to checkout solutions uploaded by our customers, partners and community members here.

Related KBs Extension

IT MonkeyIT Monkey O.G.
edited August 2016 in Cireson Uploads
This custom extension will perform a weighted search against the KB search portal API and then perform a relevance analysis against the IR/SR/CR and return the top 5 most relevent results and create both a notification at the top for the most relevent and a list on the right for the top 5 for easy access to relevent KBs

Requirements:
v5+ of the Cireson Portal

Installation:
Add the following lines to your custom.js file located in the CustomSpace folder of the Cireson Portal website directory:

/* Incident Tasks */
		app.custom.formTasks.add('Incident', null, function(formObj, viewModel){  	
			formObj.boundReady( function () {

				getRelatedKBs();

			});	
		});

/* Service Request Tasks */
		app.custom.formTasks.add('ServiceRequest', null, function(formObj, viewModel){  	
			formObj.boundReady( function () {

				getRelatedKBs();
		
			});
		}); 

/* Change Request Tasks */
		app.custom.formTasks.add('ChangeRequest', null, function(formObj, viewModel){  		
			formObj.boundReady( function () {

				getRelatedKBs();

			});
		});

Below this code in the custom.js file, you will need to paste the contents of the ext_RelatedKBs.js
Save your custom.js and then refresh your browser

Configuration:
None required.

Comments

  • Michael_BaldryMichael_Baldry Customer Advanced IT Monkey ✭✭✭
    Quick note on this. We had this extension enabled for a few months, but it stopped working around the time that we installed V5 of the portal into our environment, so we disabled it. I finally had a chance to look at it, and found that it was throwing a 404 error saying that no resource was found that matches the request URI "http://<servername>/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch?userId=<userid>&searchValue=<searchstring>&isManager=false" (with proper variables in place of the items enclosed in '<>'). I looked at the API and found that "userLanguageCode" is a required parameter; did that change in one of the more recent releases?

    In any case, switching the data object in the ajax call to include the 'userLanguageCode' has fixed this up for us. Just posting in case anyone else was running into the same problem.

    Code that wasn't working (starts at line 25 in the "ext_RelatedKB.js" file from the original post):
    "$.ajax({
    url: "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch",
    async: true, //this is the default but showing that it can be turned off
    data: {
    userId: session.user.Id,
    searchValue: searchString,
    isManager: false
    },
    type: "GET",
    ..."

    Working code:
    "$.ajax({
    url: "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch",
    async: true, //this is the default but showing that it can be turned off
    data: {
    userId: session.user.Id,
    searchValue: searchString,
    isManager: false,
    userLanguageCode: 'enu'
    },
    type: "GET",
    ..."
  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭
    edited June 2016

    Love this extension! :)
    just a minor logic error in the code regarding calculation of relevance.

            for (var j = 0; j < titleArray.length; j++) {
             var occured = occurrences(data[i].Title, titleArray[j])
             relevence += occured;
            }

    should be:

            for (var j = 0; j < titleArray.length; j++) {
             var occured = occurrences(data[i].Title.toLowerCase(), titleArray[j])
             relevence += occured;
            }

    ..as the occurrences function was not ordering relevance correctly when there was a difference in case sensitivity. (e.g.: 'SharePoint' would not match 'sharepoint'). The above change fixes this.
    Cheers,

    Adrian

  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭
    <p>&nbsp;$.ajax({<br>&nbsp;&nbsp;url: "/api/V3/Article",<br>&nbsp;&nbsp;async: true,<br>&nbsp;&nbsp;data: {<br>&nbsp;&nbsp;&nbsp;searchValue: searchString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;type: "GET",<br>&nbsp;&nbsp;success: function (data) {</p>

    So, I have been trying to write some improvements for this add-on, but have found something strange with my  ajax api search results.

    Essentially, what I am trying to do, is pull back the "key words" for different search results, and using the keywords, sort kb articles by relevance, rather than using the title of the article instead (which is less accurate).

    Unfortionately, when using "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch" or "/api/V3/Article", it only seems to pull the "Title" and "Abstract" fields from KB articles, rather than other useful fields such as the "Keywords" field. The other fields are listed, but they are all null.

    I am running Portal version 5.0.7

    Any thoughts on this would be appreciated.

    Kind Regards,

    Adrian

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    In v5 we changed the API so this will no longer work without a few changes. I'll see if I can't get those pushed in this week.
  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

    Sounds great!

    Thanks Seth

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    Updated to v1.0.3. 
    - Resolved issues with it throwing an error in a new item template when the title and description were both empty
    - Resolved an issue where even if they were both filled in it would still choke on an output string
  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
    Hu, does it still works. I try to implement in newest version but don't works. It looks that use depreciated ws command but after change to url: "api/V3/Article/FullTextSearch?searchValue={searchValue}", still nothing. Any idea?
  • Jesper_JeanssonJesper_Jeansson Customer IT Monkey ✭
    edited March 2019
    @Marek_Lefek
    I got it to work. We are using portal version 9.0.3
    Changed both url and data to this:
    $.ajax({
    	url: "/api/V3/ArticleList/Get",
    	async: true,
    	data: {
    		searchText: searchString
    	},
    I also had to change the Notificationbar to the following:
    $(".kbNotification").css({
    	'z-index': 1,
    	'top': 90,
    	'line-height': 2.5,
    	'overflow': 'hidden',
    	'box-shadow': '0 5px 5px -5px #333',
    	'background-color': 'orange',
    	'color': 'white',
    	'text-align': 'center',
    	'padding': '0px'
    }).slideDown();

    Post edit: Removed tab in code section
  • Leigh_KildayLeigh_Kilday Member Ninja IT Monkey ✭✭✭✭
    The zip fails a virus scan.

    @Jesper_Jeansson, would you please provide the full working script?
  • Jesper_JeanssonJesper_Jeansson Customer IT Monkey ✭
    edited March 2019
    The zip fails a virus scan.

    @Jesper_Jeansson, would you please provide the full working script?
    Of course: https://gist.github.com/JesperJ/d5c2e791ca2b4194a4ac5aaa70d0975d
    Note that i have the Install-lines in the begining of this file.

    I also have the following in custom.js:
    $.getScript("/CustomSpace/custom_extKB.js");

    Edit: If i violate anything by posting the script to github, please let me know and I will remove it.
Sign In or Register to comment.