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:
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
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:
Please comment if you get any errors or if you figured out how to do this in a smarter way via powershell: )
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!
tabdighurtigt.com…
Coretech Blog » Blog Archive » How to change status on Service Request templates (or other templates)…
I have tried this. but when I try to import the management pack, I get the error .
Status is not a valid property. Any suggestions
Hi Anvaj,
I cant test it right now, it could be some incongruence with the alias..but you can just replace the property with the guid of the status you need.
Let me know if it works or you need more help with finding the guid
When I run Get-SCSMEnumeration | ?{$_.Displayname -like “Pending External”}, there is no output after I’ve added my custom status to the List Properties for Activity Status. Is there something I’m missing?
Hi Joel,
You should replace “Pending External” with the display name of your custom list item. Be also aware that if you copy-paste the code from here, some of the symbols could be wrong, e.g. “”. You actually don’t have to output it to a txtfile, just format-table and select only displayname and id, like this:
Get-SCSMEnumeration | ?{$_.Displayname -like “Pending External”} | ft DisplayName, id
Let me know if it works
Hi Morten,
We tried this option and were able to chnage the status of the service request but how can now status of SRs be changed – All statues are grey out now.
were can I get this template from?
Hello Morten,
Thank you for the solution!
I’ve implemented at work – where I set the status to “complete” for SRs.
I have an issue where the SLA will continue, as there is no competition date for the work item.
Are you able to help or point me in the right direction?
Hi John,
Sorry for the late response. Regarding the Completed Date, then yes, that needs to be set before applying the template, otherwise it will be either null (or in some cases, e.g. for Incident, be a specific old static date). Unfortunately, you cannot do a [now] or similar in the template xml.
When and how are you applying the template? If it’s a normal SCSM Workflow it will be difficult to set the Completed Date, unless you don’t care about reporting you could set it to a static future date (like 2020) so it won’t mess up the SLA. If it’s via Powershell or Orchestrator (or other place), you should be able to set the Completed Date before applying the template.
Also, this is an old post, today I would advice against making new status values on the out-of-the-box status list for SR. Instead make a new custom status enumeration list, but since you are using an out-of-the-box status value – completed, it doesn’t matter.
Hi can you publish a video tutorial that can help me better.
Hi Rabbany,
No sorry, this blogpost is pretty old and as I wrote in my previous comment I advice against setting the build-in status. If you want to make custom statuses, you should make your own custom status enumeration list, and then still follow this guide to set that one.
… [Trackback]
[…] Find More on|Find More|Find More Informations here|Here you can find 39507 more Informations|Informations to that Topic: blog.ctglobalservices.com/service-manager-scsm/mme/how-to-change-status-on-service-request-templates-or-other-templates/ [……