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.

Portal Asset Search

2

Comments

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    Hey Joivan, for the sake of community discussion, how come you went with the API call you did rather than one of the other API calls, such as GetObjectByCriteria or something along those lines? This would allow you to specify additional search criteria as well as narrow down the CI types you are trying to pull in. It would also work well with pulling in just Hardware Assets, but then doing a server side criteria search for values you are passing into the script.

    Did you look at this and decide it wouldn't work for some reason, or just went with the basic CI API for another reason. Purely curious!
  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    Excellent question! Speed. 
    The GetProjectionByCriteria API call hits the ServiceManager database, which is generally pretty fast for small datasets. If you are searching through 50k+ hardwareassets, it will pull back a filtered query in a few milliseconds, which is fantastic. But if the resultset it larger - say, 1000+ assets, then it takes awhile, even with using a minimum type projection. The GetConfigItemsByAbstractClass API call hits ServiceManagement, which has significantly less overhead when pulling back a resultset with thousands of items. 

    The next question is, why would you do a quick search for 10k items? Accidentally. The query uses a dynamic textbox, with a configurable delay of 300ms. Both GetProjectionByCriteria and GetConfigItemsByAbstractClass do not let you choose a max result size, so after typing 3 characters and pausing for 300ms, the API call will start.

    For example, let's say you have 5000 assets that start with the name "dev-". You have one server named "dev-scsm01". If you type in "dev", then pause for 300ms, then continue typing the name of your unique scsm server, then you will have to wait 30+ seconds before the query returns all "dev" results, and then re-queries your one "dev-scsm01" criteria, and returns it in 131 ms. 
    This number is a bit more practical with a resultset of 1000 objects. If you look for "vmware", and it returns 1000 objects, GetConfigItemsByAbstractClass will return instantly, but GetProjectionByCriteria will take 2-5 seconds

    I've attached a similar copy of hardware asset search using GetProjectionByCriteria. This one only filters on DisplayName, just like GetConfigItemsByAbstractClass, but you'll notice quite a large slowdown in seconds when dealing with large numbers of results. 
  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    @R_Delawder The spacebar issue - I'm no longer seeing this behavior in IE11 with the newest script on a couple of test machines. What version of IE are you seeing this on?
  • R_DelawderR_Delawder Member Adept IT Monkey ✭✭
    When I fist started to try this I was on IE 10. When I installed PR 5.2 there were a lot of issues so I installed IE 11. so right now I am seeing it on IE 11 version: 11.0.9600.17843 Update version 11.0.20
  • R_DelawderR_Delawder Member Adept IT Monkey ✭✭
    I installed the latest cumulative patch that didn't seem to fix the space issue however I found something strange. when I open the developer tools (f12) it seems to work fine. as no one else seems to be having this issue other than us apparently it is environmental. thanks for trying to help.
  • Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    @Steve_Clarke

    The User Search has been updated. See attached.

    Thanks,
    Nick
  • Steve_ClarkeSteve_Clarke Customer Adept IT Monkey ✭✭
    Legendary work guys. Thanks for putting the effort into this stuff. It is greatly appreciated :)
  • Stefan_HenselerStefan_Henseler Customer IT Monkey ✭
    edited August 2016
    This is another example on how to customize the main portal search in the top header with an autocomplete: https://github.com/synax/CiresonAdvancedPortalSearch. It's based on joivans example and uses the GetProjectionByCriteria API call. I think it won't scale very well, but it works for us so far, our IT Monkey's use clever search terms :wink:
    Greetings and thanks to Geoff Ross for the best cireson health check ever :smiley: !
  • Ian_GlennIan_Glenn Customer Adept IT Monkey ✭✭

    Hi Joivan, I recently installed the v6 of the Portal in our LAB to test our customizations and the Portal Asset Search is causing issues with IE 10; I tried both versions of the script (Legacy and Non) and both cause the portal to break and cause nothing to work (views, forms, etc).  As soon as I remove the AssetSearch .js file everything goes back to working in IE 10..  IE 11 and Chrome work fine.  Here's the errors I am seeing in the console log:

    IE 10: Non-Legacy Script (this is expected per your previous comment)
    SCRIPT5009: 'MutationObserver' is undefined
    cca5abda-6803-4833-accd-d59a43e2d2cf, line 16 character 2

    IE 10: Legacy Script
    SCRIPT438: Object doesn't support property or method 'warn'
    kendo.all.min.js, line 25 character 31583

    The legacy script works fine in the v5.x version of the Portal but doesn't work in v6.

  • Stefan_HenselerStefan_Henseler Customer IT Monkey ✭

    Hi Glenn

    Are you using the search I posted or the original one from Joivan? Can you check the call stack and figure out where in the AssetSearch.js script the cause for the second exception is? I had this exception as well at some point, but can't remember where the cause in the original code was.

    Cheers Stefan

  • Ian_GlennIan_Glenn Customer Adept IT Monkey ✭✭
    Hi Stefan,  I am using the code Joivan posted on Aug 11.
  • Stefan_HenselerStefan_Henseler Customer IT Monkey ✭
    edited September 2016

    Hi Ian

    Ah ok. So I've added the legacy asset search to my test environment and now I remember. If you go up the call stack in your debugger, you will probably see the following error as well (or something like it):

    Unknown DataSource transport type 'json'., Verify that registration scripts for this type are included after Kendo UI on the page.

    in my case, this is the actual warning message, that causes IE to throw:

    SCRIPT438: Object doesn't support property or method 'warn'
    kendo.all.min.js, line 25 character 31583

    I don't know the exact root cause of this. Might is a bug of kendo in IE10 or so. Chrome and Firefox work for me without issues. So after a little bit of googling, I came across this post, which pointed me into the right direction:

    http://stackoverflow.com/questions/36948916/kendo-ui-grid-datasource-and-rest-api

    So what I did to get rid of the error and make it work in IE10/11, I removed the json options from the datasource (Removed the bold line (Line 55 and 48 of the original script)):

     var thisDataSource = new kendo.data.DataSource({
                type: "json",
       serverFiltering: true,
                transport: {
                    read: {
         type:"POST",
         url:"/api/V3/Projection/GetProjectionByCriteria",
         contentType: 'application/json; charset=UTF-8',
         dataType: "json"
        },

    This doesn't solve the root cause, but it doesn't throw the warning anymore and the search should also work in IE :).

  • Ian_GlennIan_Glenn Customer Adept IT Monkey ✭✭
    Stefan, which file did you modify?  I don't see those lines in "custom_HardwareAssetSearch.js".  Thanks
  • Ian_GlennIan_Glenn Customer Adept IT Monkey ✭✭
    edited September 2016
    Stefan, thanks for your help, I figured out which line to remove..

    $("#searchAsset").kendoAutoComplete({
       dataTextField: "DisplayName",
       filter: "contains",
       placeholder: "Type the name...",
       minLength: 3,
       delay: 500,
       dataSource: {
        // type: "json",   <-- I removed this line and now the search works in IE10/11 and Chrome.
        serverFiltering: true,
        transport: {
         read: {
          url:"/api/V3/Config/GetConfigItemsByAbstractClass?userId=" + session.user.Id + "&isUserScoped=false&objectClassId=c0c58e7f-7865-55cc-4600-753305b9be64"
         },
         parameterMap: function (options) {
           return { searchFilter: options.filter.filters[0].value };
         }
        }
       },
  • Stefan_HenselerStefan_Henseler Customer IT Monkey ✭
    edited September 2016

    Hey Ian, Sorry for posting the wrong code... I used the code from the version I posted on the 28th. I'm glad you found it and it that it works for you now! Cheers!

  • Steve_ClarkeSteve_Clarke Customer Adept IT Monkey ✭✭
    Thanks guys. Hit the same problem after upgrading to v6 of the portal. Removing the json line resolved the issue.
  • Dave_ChristensenDave_Christensen Customer IT Monkey ✭
    This is a great resource, thanks for posting.
  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    This has now been updated to work with the Portal v6 and IE in the attached file. There's no new functionality in this one, just Portal V6 + IE compatibility. 
  • R_DelawderR_Delawder Member Adept IT Monkey ✭✭
    Thanks new version seems to have corrected issue I was having with space not working.
  • Martyn_FearnMartyn_Fearn Customer Adept IT Monkey ✭✭

    Hi,

    We are getting the following error with this but only in our PROD environment (works fine in Acct).  The message clearly points towards permissions but as far as I can see everything is exactly the same in both environments.

    This happens after entering a CI name and clicking it.  A new page opens with the following message.  Any ideas anyone?

    TIA


  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    @Martin_Lien Are you able to browse to your list of hardware assets and open up all of them without using HWA Search? Next, if you are an SCSM admin who is in the Portal Asset Managers role, does HWA Search still give you this same error? 
  • Martyn_FearnMartyn_Fearn Customer Adept IT Monkey ✭✭

    I have always had trouble with browsing the 'Hardware Assets - All' list.  It never actually returns any items and causes the portal to perform really badly while it thinks about it.  This may be due to the large number of Hardware assets we have.

    However, we only have a few Software Assets currently whilst we continue to build the list.  When clicking on 'Software Assets - All' it does return the correct list.  If I try and open any of those I get exactly the same error message.

    I have no such problem when trying to open / edit Hardware or Software assets within the SCSM console using the same account.


  • Steve_ClarkeSteve_Clarke Customer Adept IT Monkey ✭✭
    edited March 2017

    Hi @Martyn_Fearn. It sounds to me like the account you are using has been given access to the Navigation menu options (through Navigation Settings) but is not in the "AssetManagerADGroup" defined in the Cireson Portal Admin Settings (or during the install of the Portal where it prompts you for an Asset Manager AD Group)

    Check if the user account you are using is in the "AssetManagerADGroup" that is defined in the Cireson Portal admin settings page. as this gives access to the asset form in the portal. If you only have given access to the Navigation menu, you can only see the "Software/Hardaware Assets - All" grid view. But attempting to click on an asset will give you the error above.

    This would also explain why you can make the changes in the Console as your account is probably in the correct Role group (even basic analysts can read assets in the console) but need to be in the group above to do so in the portal.

  • Martyn_FearnMartyn_Fearn Customer Adept IT Monkey ✭✭
    Hi Steve,
    Thanks for this.
    I have checked and the account I'm using is definitely in the AD group defined in the Admin settings (AssetManagerADGroup).  I've also confirmed this by querying the account directly on the database and can see it is a 'Asset Manager'.
    I think I'll have to raise a support call because I can't see what is wrong at all.
  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    In my environment I also had to make sure everyone has access to edit Configuration items. Since the Asset Management workflows relate Workstations and Software Items to Assets you should verify the AssetManagerADGroup also has edit rights on CI's
    HTH
  • Cindy_BoyerCindy_Boyer Customer IT Monkey ✭
    I put this code on my DEV environment and it worked great. I put the very same thing on my TEST environment and the Hardware Asset Search field did not show up in my Hardware Assets slide-out menu. However, if I actually log in to the web server and start the Portal from there, I do see that it works. Any ideas?
  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    I put this code on my DEV environment and it worked great. I put the very same thing on my TEST environment and the Hardware Asset Search field did not show up in my Hardware Assets slide-out menu. However, if I actually log in to the web server and start the Portal from there, I do see that it works. Any ideas?
    Do you have more than one portal server for that environment? Did you unblock the files (depending on how you moved them)? Sounds like something is configured funky with that portal, as this should just be loading some javascript and css.
  • Cindy_BoyerCindy_Boyer Customer IT Monkey ✭

    Yes, we have 2 Portal servers, and I tried both. We have a copy that syncs the custom space folder. What exactly do you mean "unblock the files"?

  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭

    Hi, this script is great, but I have little question. After Submiting search by clicking "Enter" button, the Workitem search site is opening. Is there a possibility to open Asset search site?


  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭

    Hi, this script is great, but I have little question. After Submiting search by clicking "Enter" button, the Workitem search site is opening. Is there a possibility to open Asset search site?


    Hi Marek,
    Are you wanting to change the out-of-box Portal search at the top of the page so that it searches for hardware assets, in addition to work items, Knowledge articles, and Service Catalog items? Up above, it looks like @Stefan_Henseler created a similar customization. Perhaps this is what you are looking for?
Sign In or Register to comment.