Anatomy of a view

I posted this over on Technet Forums, but I figured it would be a good idea to archive it here as a reference. I’ll probably be doing this a lot more, At least until a pay the Aaron back for Helping Me

The question came up how to Copy a view. this gave me a good opportunity to drone on a bit about how a view works in XML, and what each part means, at a high level. Forewarned: we’re going to get dirty and crawl into the XML.

A view definition in the Management Pack XML looks something like this:

  <Categories>
    <Category ID="Category.View.ExampleView.ViewTasks" Target="View.ExampleView" Value="EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.ViewTasks" />
    <Category ID="Category.View.ExampleView.CreateTypeCategory" Target="View.ExampleView" Value="EnterpriseManagement1!Microsoft.EnterpriseManagement.ServiceManager.UI.Authoring.CreateTypeCategory" />
  </Categories>
  <Presentation>
    <Views>
      <View ID="View.ExampleView" Accessibility="Public" Enabled="true" Target="CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident" TypeID="EnterpriseManagement!GridViewType" Visible="true">
        <Category>NotUsed</Category>
        <Data>
          <Adapters>
            <Adapter AdapterName="dataportal:EnterpriseManagementObjectProjectionAdapter">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter</AdapterType>
            </Adapter>
            <Adapter AdapterName="viewframework://Adapters/AdvancedList">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.ViewFramework</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter</AdapterType>
            </Adapter>
            <Adapter AdapterName="omsdk://Adapters/Criteria">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.SdkCriteriaAdapter</AdapterType>
            </Adapter>
          </Adapters>
          <ItemsSource>
            <AdvancedListSupportClass DataTypeName="" AdapterName="viewframework://Adapters/AdvancedList" FullUpdateAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" DataSource="mom:ManagementGroup" FullUpdateFrequency="100" Streaming="true" IsRecurring="true" RecurrenceFrequency="{x:Static s:Int32.MaxValue}" UpdateItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" AppendItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" RemoveItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" xmlns="clr-namespace:Microsoft.EnterpriseManagement.UI.ViewFramework;assembly=Microsoft.EnterpriseManagement.UI.ViewFramework" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib">
              <AdvancedListSupportClass.Parameters>
                <QueryParameter Parameter="TypeProjectionId" Value="$MPElement[Name='CustomServiceManager_IncidentManagement_Library!System.WorkItem.Incident.ProjectionType']$" />
              </AdvancedListSupportClass.Parameters>
            </AdvancedListSupportClass>
          </ItemsSource>
          <Criteria>
            <QueryCriteria Adapter="omsdk://Adapters/Criteria" xmlns="http://tempuri.org/Criteria.xsd">
              <Criteria>
                <FreeformCriteria>
                  <Freeform>
                    <Criteria xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">
                      <Expression>
                        <SimpleExpression>
                          <ValueExpressionLeft>
                            <Property>$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Status$</Property>
                          </ValueExpressionLeft>
                          <Operator>NotEqual</Operator>
                          <ValueExpressionRight>
                            <Value>{bd0ae7c4-3315-2eb3-7933-82dfc482dbaf}</Value>
                          </ValueExpressionRight>
                        </SimpleExpression>
                      </Expression>
                    </Criteria>
                  </Freeform>
                </FreeformCriteria>
              </Criteria>
            </QueryCriteria>
          </Criteria>
        </Data>
        <Presentation>
          <Columns>
            <mux:ColumnCollection xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:datebinding="clr-namespace:Microsoft.EnterpriseManagement.UI.Extensions;assembly=Microsoft.EnterpriseManagement.UI.Extensions" xmlns:data="clr-namespace:Microsoft.EnterpriseManagement.UI.Extensions;assembly=Microsoft.EnterpriseManagement.UI.Extensions" xmlns:appCommon="clr-namespace:Microsoft.EnterpriseManagement.ServiceManager.Application.Common;assembly=Microsoft.EnterpriseManagement.ServiceManager.Application.Common" xmlns:toolbox="clr-namespace:Microsoft.EnterpriseManagement.UI.WpfToolbox;assembly=Microsoft.EnterpriseManagement.UI.FormsInfra" xmlns:slaBinding="clr-namespace:Microsoft.EnterpriseManagement.ServiceManager.SLA.Common;assembly=Microsoft.EnterpriseManagement.ServiceManager.SLA.Common" xmlns:converters="clr-namespace:FreemanRU.AdvancedViewEditor.Converters;assembly=FreemanRU.AdvancedViewEditor">
              <mux:Column Name="Id" DisplayMemberBinding="{Binding Path=Id}" DisplayName="Id.f6f897efc62647bcaadedb866656d1c2" Property="Id" DataType="s:String" />
              <mux:Column Name="Title" DisplayMemberBinding="{Binding Path=Title}" DisplayName="Title.26263470457a41d5adadfa0c434437ef" Property="Title" DataType="s:String" />
              <mux:Column Name="AffectedUser.DisplayName" DisplayMemberBinding="{Binding Path=AffectedUser.$DisplayName$}" DisplayName="DisplayName.92f6e36772c74a56b6aacf95d9629bdd" Property="AffectedUser.$DisplayName$" DataType="s:String" />
              <mux:Column Name="AffectedUserCity" DisplayMemberBinding="{Binding Path=AffectedUser.City}" DisplayName="City.05ceaa35099545dabb41cc6cf9ccc007" Property="AffectedUser.City" DataType="s:String" />
              <mux:Column Name="AffectedUserCountry" DisplayMemberBinding="{Binding Path=AffectedUser.Country}" DisplayName="Country.c0b46c2bbd724463bb05f4af0b14e896" Property="AffectedUser.Country" DataType="s:String" />
              <mux:Column Name="Classification.Ordinal" DisplayMemberBinding="{Binding Path=Classification.DisplayName}" DisplayName="Classification.f61ee15142744c078ec09152ec20f8f7" Property="Classification.Ordinal" DataType="s:Double" />
              <mux:Column Name="CreatedByUserDisplayName" DisplayMemberBinding="{Binding Path=CreatedByUser.$DisplayName$}" DisplayName="DisplayName.e3d4064379e042e799711eba13f32e80" Property="CreatedByUser.$DisplayName$" DataType="s:String" />
              <mux:Column Name="CreatedDate" DisplayMemberBinding="{converters:DataTimeBinding Path=CreatedDate}" DisplayName="CreatedDate.003a2bf6768740369bb7c433062e0198" Property="CreatedDate" DataType="s:DateTime" />
              <mux:Column Name="Status.Ordinal" DisplayMemberBinding="{Binding Path=Status.DisplayName}" DisplayName="Status.82ebd8aec7664d25919cc164834a0fc7" Property="Status.Ordinal" DataType="s:Double" />
              <mux:Column Name="Priority" DisplayMemberBinding="{Binding Path=Priority}" DisplayName="Priority.923ad1a9edcf43258dd3e9c0191e1f95" Property="Priority" DataType="s:Int32" />
              <mux:Column Name="TargetResolutionTime" DisplayMemberBinding="{converters:DataTimeBinding Path=TargetResolutionTime}" DisplayName="TargetResolutionTime.deecb7b1cc5c45bfae92976d1c334d30" Property="TargetResolutionTime" DataType="s:DateTime" />
              <mux:Column Name="AssignedUser.DisplayName" DisplayMemberBinding="{Binding Path=AssignedUser.$DisplayName$}" DisplayName="DisplayName.2df89e52b59b41569f91ff77184c9c33" Property="AssignedUser.$DisplayName$" DataType="s:String" />
            </mux:ColumnCollection>
          </Columns>
          <AdditonalProperties />
          <ViewStrings>
            <ViewString ID="Id.f6f897efc62647bcaadedb866656d1c2">$MPElement[Name="Id.08d59fbaaf094fa494ee228f4bed868d"]$</ViewString>
            <ViewString ID="Title.26263470457a41d5adadfa0c434437ef">$MPElement[Name="Title.aa32bb70bdd6490b81a5ee4acc4ed57b"]$</ViewString>
            <ViewString ID="DisplayName.92f6e36772c74a56b6aacf95d9629bdd">$MPElement[Name="DisplayName.4afd74b4dfa8498884f4e120678dc2c2"]$</ViewString>
            <ViewString ID="City.05ceaa35099545dabb41cc6cf9ccc007">$MPElement[Name="City.735e72dafbba40aeadcc0200d2c5fe94"]$</ViewString>
            <ViewString ID="Country.c0b46c2bbd724463bb05f4af0b14e896">$MPElement[Name="Country.5e6900627dd94f6ba7b94e83cae9238e"]$</ViewString>
            <ViewString ID="Classification.f61ee15142744c078ec09152ec20f8f7">$MPElement[Name="Classification.3b6c587e55904fb986e5233a56671c10"]$</ViewString>
            <ViewString ID="DisplayName.e3d4064379e042e799711eba13f32e80">$MPElement[Name="DisplayName.430b2a08785d42e1a4cb9cdcd426bbfa"]$</ViewString>
            <ViewString ID="CreatedDate.003a2bf6768740369bb7c433062e0198">$MPElement[Name="CreatedDate.253c7c6523b64db1aaeb9f23303762a4"]$</ViewString>
            <ViewString ID="Status.82ebd8aec7664d25919cc164834a0fc7">$MPElement[Name="Status.79c5338c0043490d9df72839db2087c7"]$</ViewString>
            <ViewString ID="Priority.923ad1a9edcf43258dd3e9c0191e1f95">$MPElement[Name="Priority.69f02f33586c4309bbb5f49e25c17bf8"]$</ViewString>
            <ViewString ID="TargetResolutionTime.deecb7b1cc5c45bfae92976d1c334d30">$MPElement[Name="TargetResolutionTime.382ff92378c94a6e8da60d287131357d"]$</ViewString>
            <ViewString ID="DisplayName.2df89e52b59b41569f91ff77184c9c33">$MPElement[Name="DisplayName.a7431083cddf4b99b7c0b09d291db6c3"]$</ViewString>
          </ViewStrings>
        </Presentation>
      </View>
    </Views>
    <FolderItems>
      <FolderItem ElementID="View.ExampleView" ID="FolderItem.3805a586afae4168aa61b8bab3a393d6" Folder="Folder.4d7d44f874614e02aba2cfcf33a422b0" />
    </FolderItems>
    <ImageReferences>
      <ImageReference ElementID="View.ExampleView" ImageID="CustomServiceManager_IncidentManagement_Library!IncidentMgmt_IncidentClass_16" />
    </ImageReferences>
    <StringResources>
      <StringResource ID="Id.08d59fbaaf094fa494ee228f4bed868d" />
      <StringResource ID="DisplayName.4afd74b4dfa8498884f4e120678dc2c2" />
      <StringResource ID="Title.aa32bb70bdd6490b81a5ee4acc4ed57b" />
      <StringResource ID="City.735e72dafbba40aeadcc0200d2c5fe94" />
      <StringResource ID="Country.5e6900627dd94f6ba7b94e83cae9238e" />
      <StringResource ID="DisplayName.430b2a08785d42e1a4cb9cdcd426bbfa" />
      <StringResource ID="Classification.3b6c587e55904fb986e5233a56671c10" />
      <StringResource ID="CreatedDate.253c7c6523b64db1aaeb9f23303762a4" />
      <StringResource ID="Status.79c5338c0043490d9df72839db2087c7" />
      <StringResource ID="Priority.69f02f33586c4309bbb5f49e25c17bf8" />
      <StringResource ID="TargetResolutionTime.382ff92378c94a6e8da60d287131357d" />
      <StringResource ID="DisplayName.a7431083cddf4b99b7c0b09d291db6c3" />
    </StringResources>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="View.ExampleView">
          <Name>My Example Incidents View</Name>
        </DisplayString>
        <DisplayString ElementID="Id.08d59fbaaf094fa494ee228f4bed868d">
          <Name>ID</Name>
          <Description>Work item ID</Description>
        </DisplayString>
        <DisplayString ElementID="DisplayName.4afd74b4dfa8498884f4e120678dc2c2">
          <Name>Affected User</Name>
          <Description>Display name</Description>
        </DisplayString>
        <DisplayString ElementID="Title.aa32bb70bdd6490b81a5ee4acc4ed57b">
          <Name>Title</Name>
          <Description>Title</Description>
        </DisplayString>
        <DisplayString ElementID="City.735e72dafbba40aeadcc0200d2c5fe94">
          <Name>City</Name>
          <Description>City</Description>
        </DisplayString>
        <DisplayString ElementID="Country.5e6900627dd94f6ba7b94e83cae9238e">
          <Name>Country</Name>
          <Description>Country</Description>
        </DisplayString>
        <DisplayString ElementID="DisplayName.430b2a08785d42e1a4cb9cdcd426bbfa">
          <Name>Created By</Name>
          <Description>Display name</Description>
        </DisplayString>
        <DisplayString ElementID="CreatedDate.253c7c6523b64db1aaeb9f23303762a4">
          <Name>Created date</Name>
          <Description>Created date</Description>
        </DisplayString>
        <DisplayString ElementID="Status.79c5338c0043490d9df72839db2087c7">
          <Name>Status</Name>
          <Description>Status</Description>
        </DisplayString>
        <DisplayString ElementID="Priority.69f02f33586c4309bbb5f49e25c17bf8">
          <Name>Priority</Name>
          <Description>Priority</Description>
        </DisplayString>
        <DisplayString ElementID="TargetResolutionTime.382ff92378c94a6e8da60d287131357d">
          <Name>Resolve by</Name>
          <Description>Target resolution time</Description>
        </DisplayString>
        <DisplayString ElementID="DisplayName.a7431083cddf4b99b7c0b09d291db6c3">
          <Name>Assigned To</Name>
          <Description>Display name</Description>
        </DisplayString>
        <DisplayString ElementID="Classification.3b6c587e55904fb986e5233a56671c10">
          <Name>Classification category</Name>
          <Description>Incident classification category</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>

To break that down:

  1. Categories controls what right-click options show up
  2. The View definition (in the <View> block, surprisingly), consists of:
    1. The Data Block containing:
      1. Adataptors, how to get data
      2. Item Sources, where to get data
      3. and Criteria, what to filter
    2. the Presentation Block, containing:
      1. the column bindings, with what columns and how to populate them
      2. and ViewStrings, column names
  3. The FolderItem block, showing where the view should attach to the tree
  4. ImageReference (optional) showing what picture to use in the tree
  5. StringResources, connecting Viewstrings to LanguagePack DisplayStrings
  6. and Display Strings, showing what to the StringResource, and by extension ViewStrings, should read in various languages.

If you wanted to copy this view in a management pack, you would need to export the MPXML to a text file, find all of the components of the view definition, and insert new copies with updated IDs so the old view and the new view could be edited independently.

Also, let me strongly recommend the advanced view editor. it’s a wonderful tool that helped me a lot at previous engagements. I haven’t used the pro edition, because it’s been a while since I’ve done much view design, but the Free edition was indispensable.

Advertisements

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