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.
Comments
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!
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.
The User Search has been updated. See attached.
Thanks,
Nick
Greetings and thanks to Geoff Ross for the best cireson health check ever !
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.
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
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 .
$("#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 };
}
}
},
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!
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
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.
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.
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.
HTH
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"?
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?
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?