When dealing with Incidents, you and your Service Desk people always want the most important information at hand to work effectively. One requirement could be to display information about incidents without opening them. Out of the box this is possible and the SM console displays the most important information about a selected Incident in a preview form. This is indeed helpful, but what if you want to display other information in the preview? Well, that’s possible with a little bit of advanced customization. Just read on …
Before we start let’s have a quick look at the situation without any customization. I’m sure you are very familiar with this …
Now let’s take a look at the two needed steps to change the default preview form.
Step 1 – Management Pack
First of all I create a new Management Pack and add some references:
<ManagementPack ContentReadable=”true” SchemaVersion=”1.1″ OriginalSchemaVersion=”1.1″ xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>
<Manifest>
<Identity>
<ID>Incident.Preview</ID>
<Version>7.0.6555.0</Version>
</Identity>
<Name>Incident.Preview</Name>
<References>
<Reference Alias=”EnterpriseManagement”> <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>
<Version>7.0.6555.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias=”Incident”>
<ID>System.WorkItem.Incident.Library</ID>
<Version>7.0.6555.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias=”AuthoringForms”> <ID>Microsoft.EnterpriseManagement.ServiceManager.Authoring.Forms</ID>
<Version>7.0.6555.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias=”WorkItem”>
<ID>System.WorkItem.Library</ID>
<Version>7.0.5826.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
Next I need to create a Type Projection. It uses the Incident class as the seed class and has two components, the “Affected User” and the “Assigned to” User of the Incident. This is needd because I want to display details about the affected user in the preview form. Check the Alias of the components as they are very important to later bind the data to the form.
<TypeDefinitions>
<EntityTypes>
<TypeProjections>
<TypeProjection ID=”TypeProjection.Incident” Accessibility=”Public” Type=”Incident!System.WorkItem.Incident”>
<Component Path=”$Target/Path[Relationship=’WorkItem!System.WorkItemAssignedToUser’]$” Alias=”AssignedTo” />
<Component Path=”$Target/Path[Relationship=’WorkItem!System.WorkItemAffectedUser’]$” Alias=”AffectedUser” />
</TypeProjection>
</TypeProjections>
</EntityTypes>
</TypeDefinitions>
The next section defines the categories. The first category is a default category, the second category is used to declare the form with the ID “form.incident.preview” (which is defined later in the MP) as the preview form for Incidents.
<Categories>
<Category ID=”Category.Basis” Value=”EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack”>
<ManagementPackName>Incident.Preview</ManagementPackName>
<ManagementPackVersion>7.0.6555.0</ManagementPackVersion>
</Category>
<Category ID=”Category.Incident.Preview” Target=”Form.Incident.Preview” Value=”EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.OverviewForm”>
</Category>
</Categories>
In the presentation section of the MP, I need to define the preview form and configure the target, in this case the type projection in this MP. The assembly comes from Visual Studio (described later) and will be bundled together with the MP. Because one assembly could have more than one form, the “TypeName” defines what form to use. This needs to match the xaml-file in the Visual Studio project, but we’ll see that later.
<Presentation>
<Forms>
<Form ID=”Form.Incident.Preview” Accessibility=”Public” Target=”TypeProjection.Incident” Assembly=”assembly.incident.preview” TypeName=”Incident.Preview.Preview”>
<Category>Form</Category>
</Form>
</Forms>
</Presentation>
Nothing special in the languages section …
<LanguagePacks>
<LanguagePack ID=”ENU” IsDefault=”false”>
<DisplayStrings>
<DisplayString ElementID=”Incident.Preview”>
<Name>Incident.Preview</Name>
<DisplayString>
<DisplayString ElementID=”Form.Incident.Preview”>
<Name>Form.Incident.Preview</Name>
<Description>Incident Preview Form</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
In the presentation section I referenced an assembly. Now in the resources section of the MP, that assembly needs to be declared. The filename is important later when the MP is bundled together with the MP.
<Resources>
<Assembly ID=”assembly.incident.preview” Accessibility=”Public” FileName=”Incident.Preview.dll” HasNullStream=”false” QualifiedName=”Incident.Preview, Version=1.0.0.0″ />
</Resources>
</ManagementPack>
That’s it with the MP part. Now, lets create the preview form.
Step 2 – Create the Preview form
In Visual Studio I create a new User Control project – I call it “Incident.Preview”.
Next I delete the UserControl1.xaml file and create a new xaml file with a meaningful name – in my case I select “Preview”.xaml”. This name (the form name) is important because it is referenced in the MP, remember? If not, check step 1 again.
Now comes the fun part – forms design! I’m not really good in this, so I will keep it very simple 🙂 I drag the needed controls for the preview to the form and do the needed formating. Because the preview form is read-only, I only use label controls.
As soon as the formating is done, the data binding needs to be configured. Instead of using a label text, I just need to define what information should be displayed by binding the label text to the attribute of interest. In this example I want to display some information about the affected user of the selected Incident.
As you can see, the label content has no text but contains a binding to the needed property. I’m configuring a form for the Incident class, but I want to display information about the affected user. This is where the MP with the Type Projection and the components (Affected User) comes into play. The Alias of that component is used together the property name. In the example below the Alias is “AffectedUser” and the property name that holds the value that I want to display is “Company”.
<Label Content=”{Binding Path=AffectedUser.Company}” …
Now let’s build the User Control in Visual Studio. After that you can copy the dll file from the projects folder and store it in the same folder as your MP file, so that they can be bundled together. To do the bundling we need the well-known “new-mpbfile.ps1” script.
After the files have been bundled, import the bundle and (after restarting the SM console) check if the preview form shows up as expected. Just mark an incident and check the form. Cool, huh?
OK, the design could be better, but this is your job now
Update: You can download the VS project here –> https://skydrive.live.com/#!/?cid=5752db4b025958b6&sc=documents&uc=1&id=5752DB4B025958B6%21253
regards
Marcel
Excellent article, thanks very much!
We are encountering problems. importing the mpb file works fine but when i click on a incident and the preview pane should show up im getting an error and no preview pane is shown. anyone else also encountering this problem?
Hey
Strange. I guess you have a problem in the dll or in the MP file ( section). Some more details about the error would be helpful.
regards
Marcel
Hi Marcel,
Thanks for your answer here is a document with the error im getting:
http://www.filedropper.com/error
I think the problem is in the dll but i cant figure it out 😦
The error says that the assembly could not be loaded. check again the complete procedure. also make sure that the assembly is compiled for the correct architecture (x86, x64 …).
regards
Marcel
I now compiled it for x64 architecture but is also not working.. Is it possible that you show me more of the files i have to create? like the XML file and maybe the sln file?
Hey
I uploaded the project to my skydrive. Get it here –> https://skydrive.live.com/#!/?cid=5752db4b025958b6&sc=documents&uc=1&id=5752DB4B025958B6%21253
regards
Marcel
Thanks very much Marcel. I still don’t know what we did wrong but now it is working! 😀
Im Screenshot scheint noch ein Fehler zu existieren, in der 6. Zeile der Language Section: Der Display String nicht geschlossen.
Hallo Markus
Habs korrigiert, danke für den Tipp!
Gruss Marcel
This is a nice solution, works great. Just wondering if you can suggest how this can be applied to change request previews?
Thanks
Hey
This should work more or less the same as with incidents. But I never used/tried it myself …
Cheers
Marcel
Hello Marcel, I want to change the preview of the Change Request. To create the correct Management Pack, how can i find the management packs to depend on??
How can you add Incident Status and Category to the preview?
Hey
What does not work for you?
Cheers
Marcel
Pingback: Issue with preview and customization form in the SCSM – SCSM: all for administration and development
Hello, do you happen to still have the solution for this? I have tried to build it for SCSM 2019 and am getting an error in the preview pane that states there is an issue with the Presentation/form section.