Skip to main content

Creating a Decimal Property in the Service Manager Authoring Tool

Author by Christopher Mank

In the Service Manager Authoring Tool, we are able to create new Configuration or Work Item classes, seal them in a Management Pack (MP) and import them right into Service Manager.  One of the more common custom classes I find myself creating is a "Catalog" class.  This class can be used to show your business customers the standard set of hardware and software they can order from IT.  Such things like Workstations, Laptops, Docking Stations, and Software Packages can all be added to this class.  You can then publish this out to the Self-Service Portal for users to be able to order their equipment online. In the Authoring Tool, one of the data types that you are allowed to create is a Decimal.  This data type is extremely useful when you want to display the price of the catalog item.  This seems pretty straightforward, right?  Well let's take a look. I first created a new MP and called it TestMP.  I then added a new Configuration Item class called Catalog and added some properties.  One of the properties is called Price.  As you see, I have given it a data type of Decimal. After sealing this MP, I went ahead and imported it into Service Manager and created a View for my new class.  I then created a new catalog item as shown below and gave it a price of 799.25 and clicked OK. But wait a minute, when you back into the form, the price gets rounded down to 799.  What's more, if you put in something like 799.70, the price gets round up to 800.  So what gives? The answer lies in how the Decimal data type works in .NET.  The Decimal data type has a property called Scale.  Scale is the number of digits to the right of the decimal point in a number.  If we pop open our MP that we created earlier and find where we created our Price property, we will see that the Scale, by default, is set to 0. If we change this value to 2 and reimport our MP, we can now save decimal values correctly.  Also as a note, you CANNOT set the scale value using the Authoring Tool.  This will have to be edited manually in the XML. Until the Whole World Hears… Christopher

Christopher Mank

Systems Architect