How to change status on Service Request templates (or other templates)

 

As google didn’t help I decided to make a small how-to guide on how to modify the status on a template that can’t be done in the console. I’ll use a Service Request template as example here, but it’s the same method for other templates as well.

1. Introduction

 

When editting a service request template in the console you’re presented with this:

ServiceRequestTemplate1

Unlike the Incident template form there is no option to change the status. Either if you want some of the default ones (Cancelled, Completed, Closed etc.) or if you added your own Status in the enumeration list (e.g. Pending User).

This is how I did it with a bit of Management Pack XML editting and powershell:

2. Step-by-step guide

 

1) Add your own Status (optional)

Add some new Status values in the Service Request Status enumeration List (skip this step if you just want to use the standard statuses). I’ve added Pending User and Pending External

image

2) Create template

Create a new Service Request template and change atleast one list property, e.g. change Source to Portal. This is required to save the template, but also to add the right reference in the MP that we need to use. You can always delete this property in the MP again.

3) Save and export

Export the Management Pack where you saved the template and open it.

4) Locate your template in the XML

Now we need to update the Service Request template with the right property. Locate your template in the xml file. It should look something like this:

<ObjectTemplate ID="Template.ad71c64135a343a7b376bb9f2e820351" TypeID="ServiceRequest System.WorkItem.ServiceRequestProjection">

If you have alot of templates in the MP you can always search for the name, e.g. “Service Request – Pending User” or whatever you named your template. This will take you to the end of the xml file where the DisplayString is located. Now copy and search for the elementID (e.g. Template.ad71c64135a343a7b376bb9f2e820351) and it will (eventually) get you up to the correct location.

5) Add the Status property code

Adding a standard Status:

Right under <ObjectTemplate ID insert the <Property  …. </Property> code like this:

<ObjectTemplate ID="Template.ad71c64135a343a7b376bb9f2e820351" TypeID="ServiceRequest!System.WorkItem.ServiceRequestProjection"> 
	<Property Path="$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.ServiceRequest']/Status$">$MPElement[Name='ServiceRequest!ServiceRequestStatusEnum.Closed']$</Property>
</ObjectTemplate>

 

Here I’ve added the Status Closed. You can replace Closed with other standard Status codes for Service Request:  Submitted, Completed, Cancelled, InProgress, OnHold. E.g. $MPElement[Name='ServiceRequest!ServiceRequestStatusEnum.OnHold’]$

Delete redundant properties if needed.

Adding your own Status:

Adding your own Status code is a bit more tricky because its internal name is created as a random ID number (e.g. Enum.97f8882db09f4553a26086bdd92754bb). The custom value do have a unique ID to be used though (GUID). We can use the powershell cmdlet Get-SCSMEnumeration to retrieve this (requires smlets: http://smlets.codeplex.com/):

Open a new powershell window and type in the following:

  • Import-Module smlets
  • Get-SCSMEnumeration | ?{$_.Displayname -like "Pending External"}  #<—This will return all Enumeration values named “Pending External”. Replace it with your own name of course.
  • Put it in a variable:
  • $temp = Get-SCSMEnumeration | ?{$_.Displayname -like "Pending External"}
  • Output the ID:
  • $temp.ID > C:\temp\temp.txt  #<–make sure path exists
  • NB! If there was more than one enumeration value returned the txt will be blank. In this case select the array number your enumeration value was listed from the previous output:
  • $temp[0].ID > C:\temp\temp.txt #([0] if it was the first on the list [1] second etc.. You get the idea : ))

When you got the right GUID, simply replace the $MPElement[Name='ServiceRequest!ServiceRequestStatusEnum.OnHold’]$ with the guid. So it looks like this:

		<ObjectTemplate ID="Template.ad71c64135a343a7b376bb9f2e820351" TypeID="ServiceRequest!System.WorkItem.ServiceRequestProjection">
		      <Property Path="$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.ServiceRequest']/Status$">d614c2d6-a19a-7343-6e81-7a3210387990</Property>
			   </ObjectTemplate>

 

6) Save and import

That’s it! Save and Import the Management Pack. If everything went well, your template should have a changed status when you open it in the console:

template2

Please comment if you get any errors or if you figured out how to do this in a smarter way via powershell: )


Comments (2):

  1. The other day, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a thirty foot drop, just so
    she can be a youtube sensation. My iPad is now destroyed and she has 83 views.
    I know this is entirely off topic but I had to share it with
    someone!

  2. tabdighurtigt.com…

    Coretech Blog » Blog Archive » How to change status on Service Request templates (or other templates)…

Leave a Reply

(required)