Skip to main content

Service Manager Custom Forms–Single Instance Pickers and List Pickers

Author by John Hennen

Welcome back friends!  If you somehow made it here by accident then might I suggest you check out Part 1 and Part 2 before proceeding.  I'll wait for you to finish. All done?  Excellent!  I know at the end of part 2 I said we would talk about how to make controls disappear from your forms on demand but I'm actually going to take a time-out and fulfill a request from one of my co-workers.  So, may I present to you: how to add single instance pickers and list pickers to your custom forms! Single Instance Picker First, you have to add the necessary assembly as a reference to your project and map a namespace in your XAML to use it.  The file you need is Microsoft.EnterpriseManagement.UI.SMControls.  The reference would look like this: SCSM_SingleInstancePicker_Reference Then you create a SingleInstancePicker object like so: SCSM_SingleInstancePicker_Code Now, if you were to stop there you would notice your single instance picker would default to the base "Configuration Item" class - probably not what you want.  In order to limit the picker to the class you want you need to go find its ManagedTypeId.  To do this you need to do a little querying of the CMDB in SQL.  Proceed forthwith to the SQL server your CMDB resides on, open SQL Server Management Studio, open a new query window, and run this query: use servicemanager select * from dbo.managedtype order by TypeName This will return a list of every class in the CMDB.  Find the one you want and copy the ManagedTypeId.  Now - back to your XAML!  You need to add a property to your SingleInstancePicker declaration to reference that ManagedTypeID like so: SCSM_SingleInstancePicker_BaseClass Success!  Now, on to. List Pickers This is a very similar process to Single Instance Pickers.  You need to add the same assembly and reference as above.  You also need to do a little SQL querying to find the EnumTypeId of the enum (list) you want your picker to reference.  The query you want to use is: use servicemanager select * from enumtype order by EnumTypeName This will return every enum AND enum item in the database.  Find the base of the enum you want to use and copy its EnumTypeId.  For example, if you wanted to reference the Activity Priority list you would use the highlighted EnumTypeId as seen below. SCSM_ListPicker_Query In your XAML, the code would look like so: SCSM_ListPicker_XAML And there you have it - List Pickers and Single Instance Pickers!  Now back to our regularly scheduled program.

John Hennen

Managing Architect