Best Practice for the Service Manager DisplayName Property

Author by Christopher Mank

One of the many features that puts Service Manager (SCSM) leaps and bounds above its competitors is its extensibility.  In conjunction with the Service Manager Authoring Tool, you can create your own Configuration Items to track anything your heart desires.  Service Manager is kind of like a Mr. Potato Head.  When you purchase it, you get the base potato and some really cool accessories.  But then, you can build him and design him however you like.  Pretty cool, huh! When we consider the data model of SCSM, we see that the base object of all objects in the CMDB is the System.Entity class.  As you can see below, this abstract class contains some properties that are present on every object in the DB.  The object we are interested in for this post is the Service Manager DisplayName property. System.Entity Object Image When you look at the out-of-box forms in SCSM, you will notice that this property is never exposed on the form, meaning there is no way to manually modify it.  But if we add the column to some of our Views, we notice that the field is being populated.  So how does that work? SCSM Incident View Image The answer is form code-behind.  The out-of-box forms in SCSM contain code-behind that when you save the form, it is auto-concatenating together other properties and saving it to the DisplayName field.  As you can see above, the DisplayName of an Incident is "ID - Title". So in terms of best practice, when creating new objects in the CMDB, create custom forms using Visual Studio and add code-behind to auto-populate the DisplayName field with something that is meaningful.  There are many reasons for why this is the best approach. 1.  This is how Microsoft does it.  Designing your custom objects to follow the standards of the developers who wrote the tool is just the right thing to do.  Also, using this approach almost certainly ensures code non regression. 2.  When selecting objects in a Single Instance Picker or in a List View control (like on the Related Items tab), you are presented with the Select Objects dialog.  As you notice in the window below, you are only given the Name (DisplayName), Class and Path columns.  Since the columns in this window are not editable, it's imperative that the DisplayName field is populated with something meaningful so that when you are viewing objects in this window, you can decipher easily which object is which. SCSM Select Objects Dialog Image 3.  If you do expose the DisplayName property on your form, you are relying on the analyst entering in the data to do so in a consistent manner.  Although you can at least make the field mandatory with some form-level validation, you still can't ensure the data they are entering is what you want.  Setting it programmatically ensures it's done right every time 4.  If you do not expose the DisplayName property on your form, SCSM will by default update it for you.  Not only that, it will update it to the value of the ID field(s) of the object.  So let's say we have a custom Lease object with a default ID field of AG{0}.  When we go to select the object from the Select Object dialog, we get something like the screenshot below.  Not very useful is it? SCSM Select Objects Dialog 2 Image 5.  When you add Single Instance Pickers to your forms, they will show the DisplayName of the object selected.  If you let SCSM name this field, you will get something like this: SCSM Single Instance Picker Image However, if you auto-concatenate the DisplayName to something that is meaningful, you should get something like this: SCSM Single Instance Picker 2 Image Additional Info: 1.  When you build code-behind into your forms, it only applies to objects that are created/modified with the form in the console.  When creating/modifying objects in a CSV import, you will need to build and add the DisplayName property manually. 2.  If you are unsure on how to build custom forms and/or add code-behind, you could always use Orchestrator to update the DisplayName field for you.  You could use a Monitor Object activity that when a new object of your custom class is created, update the DisplayName field. 3.  Below you will find a snippet of code you can use to auto-concatenate and update the DisplayName property. private void UserControl_Loaded(object sender, RoutedEventArgs e) { this.AddHandler(FormEvents.PreviewSubmitEvent, new EventHandler(this.OnPreviewSubmit)); } private void OnPreviewSubmit(object sender, PreviewFormCommandEventArgs e) { /* NOTE: The use of the IDataItem interface here is not supported/documented. * This interface may change in the future and no migration path is guaranteed by Microsoft. */ IDataItem itemRegion = this.DataContext as IDataItem; String strDisplayName = itemRegion["ID"].ToString() + " - " + itemRegion["Region_Name"].ToString(); itemRegion["DisplayName"] = strDisplayName; }

Author

Christopher Mank

Systems Architect