Skip to main content

Service Manager and Orchestrator Ticket Emailing Engine - Secrets Revealed Part 1

Author by Christopher Mank

In my previous post, I showed you how you can use Service Manager and Orchestrator to email any user or group a message and then add it to the currently open ticket's Action Log. In this post, I am going to walkthrough how this solution is built.  For demonstration purposes, I will just show an IR, but this solution can be extended to work with other types of Work Items like Service Requests and Problems. 1.  First we need to extend the Incident class to include a new property called Message and a new relationship called IncidentHasWatchers.  The relationship Target is to the Active Directory User Or Group class.  If you are unsure of how to do this, there is a plethora of examples on the web that can show you how. SCSM Customize Incident Class Image 2.  The heart of the solution lies in the following post.  It describes how instead of building an entirely new form in Visual Studio and importing it into SM, we can build custom controls and add them to out-of-box forms as customizations.  Using this technique, the possibilities are truly endless.  To build the Emailing Engine, I downloaded the solution mentioned in the post and added the code I needed.  You can download the full Emailing Engine solution here. 4.  Once you have downloaded the solution, we can open it up in Visual Studio.  There are two main files that make up our custom control, the XAML file and the C# code-behind file.  The XAML file (pronounced "zammel") is where the visual elements of the control get created and configured.  You should already have a project looking similar to the below screenshot. Custom SCSM Control Image 5.  The C# (.cs) file is where all the main code-behind lives.  We can tell the XAML file that when a change is made to a control, execute some code in the CS file.  A basic example of this is a button click.  We can configure in the XAML code that when our button is clicked, it executes a block of code that is found in the CS file.  You should already have a project looking similar to the below screenshot. Custom SCSM Control C-Sharp Code-Behind Image 6.  The most important part of our solution is found in the method that is executed when an analyst clicks the Send button.  Here it is and described by color group. Red:  We get the AnalystCommentLog class and create a new object. Orange:  We set some variables based off of what the user has entered.  We set the user's message, create a new unique GUID and also determine if the user has selected the Private checkbox. Green:  We update our object with the proper values.  One thing to note here is that on the DisplayName, it is being set to "Watcher".  This gives us the ability to track action log comments that came from this control.  We'll see more of this when we get into the Orchestrator Runbook. Blue:  We then use the IDataItem interface to convert the object we created in the Red step from an Enterprise Management Object, to an IDataItem.  We can then use that to save it to our form.  The "AnalystCommentLog" towards the bottom is the alias of the type projection the form is pointing to. Purple:  Lastly, we clear out the Message textbox. Custom SCSM Control Email Engine Button Click Method Image 7.  Following the instructions from the post in Step #2, we can (1) Add our control to the existing out-of-box Incident form, (2) Seal it and create a Management Pack Bundle, and (3) Import the MPB into Service Manager. 8.  At this point, you should now have a fully functioning solution.  When you add some text to the Message textbox and click Send, a new comment is dynamically added to the Action Log. The last steps are to configure Orchestrator to send the emails.  Stay tuned for Secrets Revealed Part 2 where we'll see just how that is done. Until the Whole World Hears, Christopher


Christopher Mank

Systems Architect