Extending Search in Service Manager

Here’s one of my favorite (as yet) undocumented features in Service Manager – search extensibility. 


This is what the Search toolbar looks like normally in Service Manager (this is a Beta 2 build so it might look slightly different than what you have right now in Beta 1 or CTP2:



 


In case you didnt notice, that’s a sneak peek of the Knight Rider glossy black theme coming in Beta 2. :)


When you pull down the Search drop down menu, you have a few options:


 


 


Searching ‘All Objects’ will take the search term you provide in the textbox on the search toolbar and search the display name for every managed object in the Service Manager database – incidents, computers, change requests, disk drives, services, etc.  For you SQL buffs, this does a pretty standard LIKE ‘%<search term>%’ query.


If you know the class of object that you want to search for, you can choose that class from the menu such as Problem (coming in Beta 2), Windows Computer, Change Request, Configuration Item, etc.  If you choose one of these options it will search only the objects of that class.  This makes it pretty easy to find the ‘Print01’ computer without finding the incidents about Print01 that might have ‘Print01’ in the title of the incident.


Now, let’s suppose you wanted to frequently search by another class which we didn’t provide out of the box.  No problem (provided you don’t mind writing some simple XML)!


Remember the MP that we created awhile back to extend the Service Manager model-based database to manage overhead projectors?


It defined a class that looked like this:


<ClassType ID=Woodgrove.CI.Projector Accessibility=Public Abstract=false Base=System!System.ConfigItem>


<Property ID=SerialNumber Type=string Key=true CaseSensitive=false Required=true />


<Property ID=Manufacturer Type=string MaxLength=256 MinLength=0 Required=false />


<Property ID=Model Type=string MaxLength=256 MinLength=0 Required=false />


<Property ID=PurchaseDate Type=datetime Required=true />


</ClassType>


Let’s just add one line to that MP to make our overhead projectors searchable using the search toolbar. The magic line of XML to add to make any class searchable is to add a <Category> element like this:


<Category ID=Woodgrove.CI.Projector.Category.Search Target=Woodgrove.CI.Projector Value=System!SearchEnabled />


The ID attribute can be anything you want.  The Target attribute needs to be the ID of the ClassType you want to search.  The Value attribute needs to be System!SearchEnabled assuming you aliased the System MP as ‘System’ in the manifest section of your MP like this:



<Reference Alias=System>


<ID>System.Library</ID>


       <Version>7.0.3707.0</Version>


<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>


</Reference>


 


So the complete MP looks like this:


<?xml version=1.0 encoding=utf-8?>


<ManagementPack ContentReadable=true SchemaVersion=1.1 xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsl=http://www.w3.org/1999/XSL/Transform>


 


<Manifest>


<Identity>


<ID>Woodgrove.CI</ID>


              <Version>1.0.0.0</Version>


       </Identity>


       <Name>Woodgrove Configuration Items</Name>


       <References>


              <Reference Alias=System>


                     <ID>System.Library</ID>


                     <Version>7.0.3707.0</Version>


                     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>


              </Reference>


       </References>


</Manifest>


<TypeDefinitions>


       <EntityTypes>


              <ClassTypes>


 


<ClassType ID=Woodgrove.CI.Projector Accessibility=Public Abstract=false Base=System!System.ConfigItem>


<Property ID=SerialNumber Type=string Key=true CaseSensitive=false Required=true />


       <Property ID=Manufacturer Type=string MaxLength=256 MinLength=0 Required=false />


<Property ID=Model Type=string MaxLength=256 MinLength=0 Required=false />


       <Property ID=PurchaseDate Type=datetime Required=true />


</ClassType>


 


              </ClassTypes>


       </EntityTypes>


</TypeDefinitions>


<Categories>


 


       <Category ID=Woodgrove.CI.Projector.Category.Search Target=Woodgrove.CI.Projector Value=System!SearchEnabled />


 


</Categories>


<LanguagePacks>


       <LanguagePack ID=ENU IsDefault=true>


              <DisplayStrings>


                     <DisplayString ElementID=Woodgrove.CI.Projector>


                           <Name>Overhead Projector</Name>


                     </DisplayString>


              </DisplayStrings>


       </LanguagePack>


</LanguagePacks>


 


</ManagementPack>


 


Now, after we import this MP, we can see that Overhead Projector shows up as a search option!


 

Woodgrove.CI.xml