SCSM 2012: Asset Management Part 3 – Folders and Views

This is the third part of the blog series about my Asset Management solution for SCSM 2012 R2.

Part 1: General overview
Part 2: Authoring – Classes and Relationships
Part 4: Authoring – Forms
Part 5: Reports
Part 6: Runbook/Automation details

This part of the series covers the folders and views created with Visual Studio 2015 Community Edition (incl. VSAE).

folderviewstructure

The following details can be found in the AssetManagementViews.mp.

Folders: (Folders.mpx)

This entry creates the AssetManagement Workspace:
<Folder ID=”Folder.AssetManagementWorkspace” Accessibility=”Public” ParentFolder=”EnterpriseManagement!ServiceManager.Console.RootFolder” />

Then we have the AssetManagement Root Folder:
<FolderItem ElementID=”EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.Task.CreateFolder” ID=”FolderItem.AssetManagementRootFolder.CreateFolder” Folder=”Folder.AssetManagementWorkspace.RootFolder” />

This entry displays the view in the folder:
<FolderItem ElementID=”EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.Task.CreateGridView” ID=”FolderItem.AssetManagementRootFolder.CreateView” Folder=”Folder.AssetManagementWorkspace.RootFolder” />     

And below the root folder are all class related folders:
OtherFolders.JPG

Each folder has an icon defined through the ImageReference:
images

Views: (Views.mpx)

Each class has its own view, and I also created views for WindowsComputer objects, Users and Groups.

Here are two examples how the views are assigned to the folders:
<FolderItem ElementID=”View.ComputerAssets” ID=”FolderItem.AllComputerAssets.View” Folder=”Folder.ComputerAssets” />
<FolderItem ElementID=”View.AllWindowsComputers” ID=”FolderItem.AllWindowsComputers.View” Folder=”Folder.AssetManagementWorkspace.RootFolder” />

The views use all the same icon as the folders. Here is an example of the default config item image, which is used for the groups:
<ImageReference ElementID=”View.AllUsersandGroups” ImageID=”ConfigurationManagement!ConfigItemImage16x16″ />

For each view we also need to create two categories:

  1. To display the create class object task: (Here “Create Computer Asset”)
    <Category ID=”View.ComputerAssets.CreateAsset.Category” Target=”View.ComputerAssets” Value=”MESUA!Microsoft.EnterpriseManagement.ServiceManager.UI.Authoring.CreateTypeCategory”/>
  2. To display tasks in general:
    <Category ID=”View.ComputerAssets.ViewTasks” Target=”View.ComputerAssets” Value=”EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.ViewTasks” />

Each view needs to have a TypeProjection defined to display fields from other classes in the same view. The TypeProjection represents the reference between the two classes. TypeProjections only work, if corresponding relationships are defined.

<TypeProjection ID=”ComputerAsset.TypeProjection” Accessibility=”Public” Type=”ComputerAsset”>
<Component Path=”$Context/Path[Relationship=’AssetToCustodianRelationShip’]$” Alias=”ComponentAlias_d5fb8379_ba30_4351_9e9a_ec9fbd9a3b65” />
</TypeProjection>

In the views you use the Alias of the TypeProjection to guide Service Manager (through the relationship) to the other class fields.
The second sample TypeProjection shows the GeneralAssets view, which is the longest one, because it references all classes.

TypeProjection.jpg

View details:

Each view needs targets a class whose objects get displayed. For the GeneralAssets view it is the AssetManagementBaseClass.

<View ID=”View.GeneralAssets” Accessibility=”Public” Enabled=”true” Target=”AssetManagementMP!AssetManagementBaseClass” TypeID=”EnterpriseManagement!GridViewType” …

Then the TypeProjection needs to be referenced:

…<ItemsSource>…<AdvancedListSupportClass.Parameters>
<QueryParameter Parameter=”TypeProjectionId” Value=”$MPElement[Name=’AssetManagementMP!GeneralAsset_TypeProjection’]$” />
</AdvancedListSupportClass.Parameters>…
</ItemsSource>…

The <Criteria> area defines which objects will be displayed. We do not want to see objects with the status inactive.

…<Criteria>…
<SimpleExpression>
<ValueExpressionLeft>
<Property>$Context/Property[Type=’System!System.ConfigItem’]/ObjectStatus$</Property>
</ValueExpressionLeft>
<Operator>NotEqual</Operator>
<ValueExpressionRight>
<Value>{47101e64-237f-12c8-e3f5-ec5a665412fb}</Value>
</ValueExpressionRight>
</SimpleExpression>
…</Criteria>…

The next section in the view handles the <Presentation> of the data, i.e. which columns are displayed.

If there are assemblies which need to be referenced to display data, then they are listed in front of the columns. In our case we reference the AssetManagementForms assembly:
xmlns:local=”clr-namespace:AssetManagementForms;assembly=AssetManagementForms”>…

Each column which should be displayed needs an entry with a binding to the class parameter.  All are only for viewing therefore the mode is OneWay.

Some string examples:
<mux:Column Name=”SerialNumber” DisplayMemberBinding=”{Binding Path=SerialNumber, Mode=OneWay}” Width=”100″ DisplayName=”SerialNumber.View.GeneralAssets” Property=”SerialNumber” DataType=”s:String” />

Binding to the DisplayName of the Enum value:
<mux:Column Name=”Country.DisplayName” DisplayMemberBinding=”{Binding Path=Country.DisplayName, Mode=OneWay}” Width=”100″ DisplayName=”Country.View.GeneralAssets” Property=”Country.DisplayName” DataType=”s:String” />

And if the data comes from another class than the targeted one then you need to use the alias of the reference in the TypeProjection:
<mux:Column Name=”AssetCustodian” DisplayMemberBinding=”{Binding Path=ComponentAlias_b1f46e16_e9a0_49af_b9f5_1c9d4bb532d1.DisplayName, Mode=OneWay}” Width=”100″ DisplayName=”AssetCustodian.View.GeneralAssets” Property=”ComponentAlias_b527cd23_9043_48a2_a3c8_111ab26f0a95.DisplayName” DataType=”s:String” />

Date example:
<mux:Column Name=”GoodsReceivedDate” DisplayMemberBinding=”{datebinding:DateBinding Path=GoodsReceivedDate, Mode=OneWay}” Width=”100″ DisplayName=”GoodsReceivedDate.View.GeneralAssets” Property=”GoodsReceivedDate” DataType=”s:DateTime” />

There are also some internal fields which could be useful to be displayed: $TimeAdded$, $LastModified$.

The last part of the presentation area is <ViewStrings>. Each DisplayName of a column needs to have an entry there also:

<ViewString ID=”AssetCustodian.View.GeneralAssets“>$MPElement[Name=”AssetCustodian.View.GeneralAssets”]$</ViewString>

So, all views are build relatively the same as they are all grid views targeted to one class. The main difference are the TypeProjections and columns which are displayed.

Here are some additional links which help to understand the Presentation area:

I will publish the whole Visual Studio Project at the end of my series.

 

 

 

 

 

 

 

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: