Automatically Creating Incidents Periodically

One question I hear pretty regularly is “How do I create a recurring work item every week (or day, or month, etc.)?”  The usual case here is that there is some task that needs to be done on an ongoing regular basis such as backing up a database, checking a log file, etc.  People are looking for a way to automatically create and assign that task to somebody at the appropriate time.  First of all this serves as a reminder to do important things at the right time.  Secondly, it makes sure that the completion of that task is tracked.

To accomplish this, I used to tell people to create a rule with a schedule data source module and a command write action module which would run a custom created .exe that called the Data Access Service to insert the work item.  That’s certainly a great option as long as you know your way around XML, C#, and our APIs on the Data Access Service.  If you have something sophisticated in mind, that might still be the best option.  However, if your requirements are simple, you are in luck because now we have the authoring console!

The rest of this blog post describes how you can create a new incident on a schedule using the authoring console.

First, install the Authoring Console. It is available at the same place you downloaded (or Connect) the Service Manager product bits.  Keep in mind that the VS shell needs to be installed first and there is a .bat file you have to run after installing the Service Manager authoring console.  See the product documentation that comes with the authoring console package.

Next, start up the authoring console.

Select File –> New –> Management Pack and provide a location to save your MP to and a file name.

image

Next, right click on the Workflow Rules node in the Management Pack Explorer tree and select Create Workflow Rule.

image

Provide a Name for the Workflow Rule like ‘CreateIncidentEveryDayRule’ and click Next.

image

Leave the ‘Timer’ option selected and click Next.

image

Provide the schedule you want to create the incidents on and click Next.

image

Provide a name for the Workflow such as ‘CreateIncidentEveryDayWorkflow’ and click Next.

image

On the confirmation page click Create.

image

On the completion page click Close.

image

Now you should see the workflow designer.

image

Drag the Create Incident workflow activity from the Toolbox onto the workflow design surface.

image

Now select that activity on the design surface.  In the Properties pane you will see a bunch of parameters.  Fill them out as appropriate.

image

Right click on the Management Pack in the Management Pack explorer and choose Save.

There should be a new .dll created in the same folder where you created the management pack .xml file.  Copy that .dll to the product installation directory on each Service Manager management server (if you have more than one).  The product installation directory by default is C:\Program Files\Microsoft System Center\Service Manager 2010.

Next import the MP into Service Manager using either the MP import experience in the Management Packs view in the Administration workspace in the main console or the Import-SCSMManagementPack PowerShell cmdlet.

An incident should be created within a few seconds and from that point on according to the schedule you specified.

Similarly, using the authoring console, you could create other workflows that run on a schedule or using a database query subscription that looks for certain conditions to be true in the database.

Let us know what you think!