Creating new classes in Service Manager allows us to enter various items to the CMDB. In an enterprise, storing information about cars, furniture, mobile phones etc. can be a basic requirement. Service Manager is able to automatically discover data on computers, users and business services, but to store other items, you have to do some very simple development.
The first step of the development work is to decide, what kind of items you want to store in the CMDB and what kind of attributes you want to work with. For this example, we’ll create the following structure:
Service Manager uses classes to represent objects, such as chairs and desks. The class defines which kind of attributes can be used to describe various objects. When items are created in the CMDB, we are instantiating these classes and populating their attributes.
In this case, we will create three classes. The first one will be the FurnitureClass class, an abstract class. This class cannot be instantiated, but will be used to define some common attributes and will serve as a basis for another two classes, Chair and Desk. As all furniture have color, inventory number, a „bought on” date and an associated person who uses the given piece, these attributes are defined the Furniture level. Chairs have a further attribute, size, and desks also have a special attribute, which tells if a given desk has drawers or not.
First, you have to install Service Manager Authoring Console, which, at this moment, is in RC state, and can be downloaded from Microsoft Connect. The Authoring Console can be installed on the Service Manager server or another machine, but – in my experience – it’s simpler to work with it when it is installed on the server.
After launching the Authoring Console, you have a graphical interface, which is very similar to other Microsoft development tools. It’s easy to use and at this level, it requires zero coding experience.
Create a new management pack in File / Create. Name it „FurnitureMP”. Save it.
On the Management Pack Explorer pane, right-click to Classes and click on Create Configuration Item Class. Give it the name FurnitureClass. (Do not use the same name you gave to the management pack.) In the central pane, a new tab opens, which contains the properties of the FurnitureClass class. In the Details pane, fill the Description property, and in the Abstract field, choose True. As you can see, the comment shows, FurnitureClass cannot have instances, which means, you won’t have furniture items, only chairs and desks.
In Class properties and relationships pane, you can see what attributes and relationships our class inherited from its parent. It has Asset Status, Display Name, ID and so on. It also has relationships, for example, Owned by user. This relationship can be used to make a connection between a given furniture (a chair or a desk) and a user who uses it.
You will add three new properties, Color, InventoryNumber and BoughtOn. For „Assigned to user” you will use the already existing relationship Owned by user.
Click to the Create Property button. Enter InventoryNumber as name and click to Create. On the details pane, make this property a key by changing the value in the Key field to True. Also make it Required, because you want to refuse storing any furniture in our CMDB without an inventory number. Your class needs a key property – now it has one, so you can delete the default key, which is named Property 4 in my example. Highlight it and click to the red X to delete it.
Continue with adding another property called Color, and a third one, called BoughtOn. After creating BoughtOn, change its data type on the Details pane, and make it a „Date Time”.
Now the base class, FurnitureClass is ready, you have to define Chair and Desk. Right-click FurnitureClass and click on „Inherit from this class”. Give the name Chair to the new class, and click to Create. Then, rename the class to Chair – because the Authoring Console ignores the name entered and uses the default name „Inherited from FurnitureClass”. In the similar way, create the Desk class. It you take a look at the Class properties and relationships pane belonging to Desk or Chair, you can see that they inherit the property Color, InventoryNumber and BoughtOn from FurnitureClass.
While on the tab of Chair, click on the Create property button, and add the Size property. Switch to the Desk tab, and add a property named HasDrawers. Change the data type of HasDrawers to Bool.
With this step, creating new classes has finished.
To effectively use your classes, you have to create new forms to enter and display data. You can accomplish this in Authoring Console. In the Management Pack Explorer pane, right-click Forms and click Create. On the base class pane, select FurnitureMP from the drop-down list, highlight Chair in the tree structure, and click OK. Give the name ChairForm to the form, and click Create.
A new tab opens in the central pane. This area can be used to place various user interface elements. From the Form customization toolbox pane, drag and drop a Label to the header of the area. In the details pane, type Chair in the Content field, and change the Font Size to 14. This will be the title of our new pane. Drag another Label to the main area, and enter Inventory Number as its content. Adjust the size of the label, as needed. Drag and drop a textbox near the label, and align them (green lines help you to do so).
On the details pane, look for the Binding Path field, click to the … button, and select the InventoryNumber property from the list. This will bind the content of the text box to the value of the InventoryNumber property of the Chair object. Repeat the same process with Color and Size property. Drag and drop a new label for the BoughtOn property, then drag a Date Picker object near it. Bind it to the BoughtOn property. In a similar way, drag a new label Used by to the main area, and then place a User Picker item near it. Bind this to the „Owned by user (user) property.
The same process can be used to design the form to handle desks. The only difference is with the HasDrawers property, which is of bool type. You have to drag a checkbox item to the form, and bind it to HasDrawers. If the check box is checked, HasDrawers is True, and the Desk has drawers built-in. When the check box is unchecked, the desk is a simple one.
Importing to Service Manager
After creating the basic classes and forms, you have to do some further work on the Service Manager console.
Save the management pack and close Authoring Console. Open Service Manager console, and go to the Administration area. Right-click Management Packs, and click to Import. Browse to the folder containing your new management pack, highlight the management pack and click to Open. Import the management pack.
Switch to the Configuration items area. Click Create folder on the right pane. In the Folder name enter Furniture, and choose FurnitureMP from the Management Pack drop-down list.
Highlight the newly created folder, and click Create view on the right pane. Enter All chairs in the Name field. Scroll down to Criteria, click Browse and select Chair. Leave all other criteria unchanged. Scroll to the Display section, and select the check boxes of the properties you want to display in the new view; for example, Inventory number, Color and Size. Click OK to create the new view.
Now, if you expand the tree structure on the left side, and click to the Furniture/All chairs view, a new command named Create chair appears on the right side. Click it, fill the fields as needed, and click OK – you created your first Chair configuration item.
From now on, you can use it as any other configuration items; you can add it as affected item to incidents, if you assign a user to it, you can see it on the user’s Configuration items for which this user is a custodian and so on.
Service Desk can be easily used to store data on various configuration items, with minimal development effort. The new classes and forms presented above show only a basic example, and I’m sure about there are many further possibilities to explore. Let’s watch for the final version of the Authoring Console and the documentation to be published on Technet and System Center blogs.