Following up our posts in this series from last week, today we are going to quickly show how we can set a template ID in a Service Request template so that the template ID is always set on SR creation.
The first step in this process is to create a new Service Request template, making sure to place the template in a new management pack so it’s easy to work with and update as needed in the future:
Next, lets set a default Title and fill in the required Urgency and Priority fields. If desired, fill in any other related fields you’d like applied to the SR when the template is used:
Save the SR template. Now we are going to export the new management pack we saved the template into and make a few changes.
Open the management pack XML file that you exported with your text editor, here I’m using Visual Studio Code.
Search for the <Templates> tag with the nested <ObjectTemplate> tag. In the case that you have stored several templates in this MP we are looking for the one that has the matching /Title$ property that we set when we saved the template:
Now we are going to add our template ID property like the below image shows:
Make sure that when you are setting the property in the XML that you are targeting the ServiceRequest class, as the TemplateId property is not a property of the base WorkItem class, but the ServiceRequest class itself.
Now save the management pack and import it back into Service Manager:
That’s all there is to it! From there you can create a new SR from the newly edited template and when you view the TemplateId for the request in Powershell or the Portal you should see your preset value:
Thanks Seth, working as expected. 🙂
LikeLike