Displaying Incidents by location - Option 2

Displaying Incidents by location - Option 2

  • Comments 1
  • Likes

Option 2: Extend the incident.

The steps in Option 1 are easy to setup and give us a great view, based on the users’ registered office.  But what if your users travel around, and they want support from whichever office they’re currently at?  For this, we can’t rely on the AD attribute, we need something more flexible, on a per-incident basis.

To achieve this, we can extend the Incident class to contain a location attribute.  This can also be added to the incident form.  When logging an incident, the current office can be set, so we can see where the engineers need to go.  It’s more of a fiddly process, but really flexible. 

I’ve attached an example MP at the end, so you can check it out!

First, get the Service Manager Authoring Tool from http://www.microsoft.com/en-us/download/details.aspx?id=28726.  Once installed, open it up and create a new Management Pack.

 

Create an Office Class:

First thing, we want to create a new Configuration Item type, to keep information about my offices. 

-          Right click ‘Classes’ and select ‘Create Configuration Item Class…’

-          When prompted, call the class ‘Office’ and click OK.

 

I want to store some information about each office I manage, so I need to add a property for each attribute.

-          Click the ‘Create Property’ button

-          When prompted, call the property Address1 and click ‘Create’

If you now look at the Details pane, you’ll be able to see information about the Address1 attribute.  We can set things here like maximum length, whether it’s required, of if it’s a key (or unique) value.  Here I’ve left it all at default, apart from setting Required to True.  This is because all of my offices need a first line of the address.

Repeat the process above to create the following attributes:

-          Address 2 (not required)

-          City (required)

-          Country (required)

-          Postcode (required)

-          Name (required) 

Next thing –we have to set a key property.  This is a property which will always be unique to identify that office.  We have a few options here:

-          If you want an automatic ID, you can add an OfficeID property.  You could then set Key to true.  You could then put the default value as ‘Office{0}’, and set Auto Increment to True.  This would automatically name each office Office1, Office2, Office 2…etc.

-          If you don’t need this OfficeID method, you can just set the ‘Name’ property, so Key equals True.  This means we will simply have a unique name for each office, e.g. ‘Cardiff Depot’ or ‘London City Office’. 

In this example, I’ve gone for the second, option, so I simply changed the Key value of ‘Name’ to True.

Last thing – you may have noticed that the authoring tool automatically made a weird attribute, called something like “Property_42”.  This is there because every class always needs a key value.  As there isn’t one by default, this was created for you.

As we have now set ‘Name’ as the Key, please delete this custom property. 

 

Extend the Incident form:

Now we can hold information about offices in our CMDB, we can now extend the incident form.  This will allow me to set each incident with a location.

In the Authoring tool, find the ‘Form Browser’ tab (at the bottom right by default). 

-          Find ‘System.WorkItem.Incident.ConsoleForm’

-          Right click > View

-          The incident form will now open. 

-          At the top of the incident form, click ‘Customize’

-          A warning will appear, asking you where to save the customizations.  Select your Management Pack, and click OK.

Next, we want to add a picker to the incident form, so the analyst can pick out where the incident is.  Customizing the forms can be tricky unless you know now.  For more tips on form editing, please read http://blogs.technet.com/b/servicemanager/archive/2011/01/14/customizing-forms-part-1-adding-a-new-user-picker-control-to-the-incident-form.aspx.

From the ‘Form customization toolbox’ click ‘Label’

-          Now drag that label over, and hover above the ‘[TierQueue]:’ part of the form.

-          Move the mouse around until you see a grey panel around the tier queue label and drop-down:

-          When you see this, let go, and the label should arrange itself smartly below:

-          Repeat the process to add in a ‘Single instance picker’ control:

-          Now click on ‘Label1’

-          In the Details section, you can see all of the attributes of the label you can alter, like the font.

-          Find the ‘Content’ property, and type in whatever you want the label to say, e.g. “Office:” 

Create a Relationship:

Next up, we want to create a relationship between Incidents and offices.  This will allow us to say ‘there are 6 open incidents in the Aberystywth office’.

-          Find the ‘Class Browser’ tab, next to where the form browser tab was.

-          Click the drop-down list, and select ‘All Management Packs’

-          In the list, find ‘Incident’

-          Right click ‘Incident’ > View

-          In the ‘Management pack explorer’ view, you’ll see the Incident class:

-          This is because the Incident class is in a Sealed MP.  We need to extend it instead.

-          Right click Incident, and click ‘Extend class’

 

-          In the warning pop up, choose your management pack to store the customizations in.

-          Now, click the ‘Create relationship’ button

-          Give the relationship a name, e.g. “IncidentRelatedToOffice” 

Now, we can see the incident has a relationship, but to ‘Object’:

We want to alter that to be more specific, so it’s a relationship to only offices

-          In the details section, find the area “Value Constraints (Target)”:

-          Click in the ‘Target Class’ box and click the “…” button next to ‘Object’

-          In the pop-up, find your Office class, and select.

Now, we have created a relationship between Incidents and the Office.  The cardinality settings you see mean “One office, can relate to many Incidents”. 

Bind the form to the Office relationship

Now we have created the office class, made a relationship to Incidents and extended the form.  The last thing is to bind that form picker to the offices.

-          Open your Customized Incident form again

-          Click on the Single Instance Picker which you added earlier

-          In the details pane, find the Binding section

-          For the Binding Path property, click in the box and click the “…” button

-          In the pop-up, select your IncidentRelatedToOffice relationship

-          For Binding Mode, change to ‘Two way’

Create a Type Projection:

OK deep breath, we’re nearly there!

Next up, we want to create a type projection.  This will join together the Incident information with a relationship to the office.  All we need this for is creating views in the console later on.  This will allow us to have a single view, where we show the incident info (e.g. Title, ID, Created Date), and Office info (Office Name, Office City).

To do this, we need to open up the XML File.  So close the authoring console, and open up the MP in your favorite XML editor. 

-          First, find the <TypeProjections> section.

-          It should look something like this:


-          Select the Type value, highlighted above. Yeah, it’s ugly!

-          Now, find the </TypeProjection> where that Projection ends.

-          Underneath it, paste this in:

<TypeProjection ID="OfficeProjection" Accessibility="Public" Type="Alias_6f1b9ea5_e520_4ca3_af01_81fc277b1dd0!System.WorkItem.Incident">

          <Component Path="$Context/Path[Relationship='IncidentRelatedToOffice']$" Alias="ComponentAlias_73755d43_43a7_40fe_846e_c11ff1985b43" />

        </TypeProjection>

 

-          Make sure the Type value is exactly the same as the one above.

-          Now, the Alias value.  That should be the same as a few lines above.  In the previous type projection, you’ll see something like this:

-          Make sure the Alias highlighted green, is the same as this one.

 

Create an Office input form

OK. If you’re still following this, congrats :) 

Last thing in the authoring now, I promise!  The final thing to do, is to customize the form to input our offices.  There will be a default form created for us, but it’s a little ugly. 

-          Open your Management Pack up in the Authoring Tool again.

-          In Management Pack Explorer, Right Click Forms > Create

-          For the Base Class, select your Office class 

This will open up a blank form.  We now want to add the fields to input information about our offices.

-          From Form customization toolbox select a Panel and drag it onto the form

-          Now in the Details section, find the Layout section

-          Set the Layout and Margin as I have here:

Now, we want to add some controls into the form:

-          Drag in a Label control

-          Use the layout and margin settings below.  This will put it in top centre

 

-          Also, set the ‘Content’ property with what you want the label to say, e.g. ‘Office Details’ 

At this point, the form should look something like this:

 

Now, we want to add in some fields to write in the office details.

-          Drag in another label

-          We want this to be a little lower than the title, put to the left

-          To do this, use the settings below.

You’ll notice that we’ve just set this to be on the left, but 30 pixels down.

-          Again, change the content, to say “Office Name:”

Now, drag in a Text Box.  Change the settings to those below.  You’ll notice that the Top property says it’ll be 30 pixels down, like the label, put also 100 pixels to the right, so they don’t overlap.

Now, repeat the steps – drag in a label, and a text box.  Use the same settings, but simply change the Top property, increasing it around 25 pixels a time.

In the end, you’ll end up with something like this:

 

Bind the Text Boxes to the Office

Now the form looks good, let’s get it to bind to the Office object data.  Click on the top Text Box.

-          In the properties, find the Binding section

-          Click the “…” button in Binding Path

-          In the pop-up, select the Name property

-          Change the Binding Mode to “Two way”

-          Next, repeat the process for all the other text boxes.  Remember to bind them to the appropriate properties.  

Import it!

OK! We are done! Now Import your Management Pack into Service Manager.  Note – You will get an error, saying the MP should be sealed.  The plan is:

-          Create the views you want

-          Export it & then seal it 

Once you’ve imported the MP let’s create some views.

-          Go to the Configuration Items tab

-          On Configuration Items, right click > Create Folder

-          Give the folder name, e.g. Office Locations

-          Ensure you save it in your Management Pack 

Now, we can create the view

-          Right click on your folder > Create View

-          Give the View a name, e.g. Offices

-          Under Criteria, click the Browse button

-          In the Select a class window, click the drop-down and select “All basic classes”

-          Search & locate your ‘Office’ class

-          Next, in the Display section, tick the boxes: Name, Address1, Address2, City, Country, Postcode

-          Click OK.

Now, you can see the view of offices.  You can start added some in.  Click on your view.

-          In the Tasks pane, click ‘Create Office

-          You should now get your awesome custom form open!  Go ahead and type in some details of some of your offices! 

Finally, let’s create the Incident views.

-          In the console, go to the Work Items section

-          Right Click ‘Incident Management’ and click Create View

-          Give it a name, e.g. Incidents in Llangollen

-          Make sure you select your Management Pack to store it in

-          In the Criteria section, click “Browse”.

-          In the drop-down, click Combination Classes

-          Pick out the OfficeProjection class, which we made earlier

-          Add a filter on Status to set only show Active incidents.

-          Next, expand Incident on the left – click IncidentRelatesToOffice

-          You can see all of the Office details here, so click City and click Add

-          Modify the query, so city equals Llangollen

-          This should look like this:

-          Now, in the Display section, select which attributes of incident you want to select in the view. E.g. ID, Created Date, Title

-          Scroll down, and expand IncidentRelatedToOffice

-          Tick the office details you want to show in the view, e.g. City, Office Name etc. 

Create an Incident:

OK! Go ahead & create an incident in Service Manager. You’ll see you can click your Office picker, and select one of your offices. 

Revel in the glory

Woot! It’s done! Now, you can create all of the Incident views you want, based on your Office Locations. You can tweak all of this to do it by country, or postcode etc.

Attachment: Incident.Office.Location.xml
Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment