Log in  \/ 
x
x
x
Register  \/ 
x

14
October
2013

How to inform ex-AssignedTo analyst about the withdrawal

In this post I’d like to share one solution for Microsoft System Center 2012 Service Manager that we were recently asked. One company has a practice to notify not only the assigned analyst about a new assignment to the service desk’s ticket but also the analyst who has been withdrawn from that ticket. It asked us for help in doing that for its Service Manager setup.

It is quite easy to create a workflow in the Service Manager console to inform an analyst about the first assignment but it won’t help if you replace analysts in the form. Ketan Ghelani posted a few years ago a very useful post about creating a custom notification workflow. Ketan explained how we could use “AddRelationship” event to run a notification workflow.

Our first intension was to use “DeleteRelationship” event to do the same to notify an ex-analyst. We perfectly caught the “DeleteRelationship” event but the notification workflow didn’t notify the ex- analyst. It happened because the instance of “AssignedTo” relationship we referred had been deleted to the moment the notification workflow tried to use it.

There are numerous methods to overcome this issue. We’ve chosen to create a new relationship named “Ex-Assigned User” and kept using Ketan’s approach.

We started with defining a new relationship. I created a new management pack (SCUtils.ExAssignedUser.Library) where defined the relationship:

<RelationshipType ID="SCUtils.WorkItemWasAssignedToUserAccessibility="PublicAbstract="falseBase="System!System.Reference">

<Source ID="WasAssignedToUserMinCardinality="0MaxCardinality="2147483647Type="WorkItem!System.WorkItem" />

<Target ID="WasAssignedWorkItemMinCardinality="0MaxCardinality="1Type="System!System.User" />

</RelationshipType>

Then I sealed the management pack because we had to reference it in other management packs.

Next, we had to create a workflow that will catch “DeleteRelationship” event for “WorkItemAssignedToUser” relationship and created a new instance of our own relationship “WorkItemWasAssignedToUser”. As usual, I used SMlets PowerShell commandlets. To build a management pack with PowerShell workflow we had to use Service Manager Authoring Tool. So I opened the tool and created a new management pack called “SCUtils.ExAnalyst.WorkFlow”. Then I created a workflow using Incident class and condition “When an object of the selected class is updated”. I added Windows PowerShell Script activity to the workflow’s tree. Then I imported the following PowerShell script into the body of the activity:

$a= (get-module|%{$_.name}) -join" "

if(!$a.Contains("SMLets")) {Import-ModuleSMLets-ErrorVariableerr-Force}

# -------------------get classes and objects------------------------

$RC=Get-SCSMRelationshipClass -Name SCUtils.WorkItemWasAssignedToUser

$wi=Get-SCSMObject -Id $WorkItemGUID

$user=Get-SCSMObject -Id $UserGUID

# -------------------remove ex-ex-analyst---------------------------

Get-SCSMRelationshipObject -BySource $wi ?{$_.IsDeleted -ne "true"} ?{$_.RelationshipId -eq "90C9BB9F-98F0-B85F-3EA5-55A428B52976"} Remove-SCSMRelationshipObject

# -------------------create new ex-analyst--------------------------

New-SCSMRelationshipObject -Relationship $RC -Source $wi -Target $user -bulk

#-------------------------------------------------------------------

remove-module -name SMLets -force

The script was quite straightforward and the only tricky part was identifying the GUID of SCUtils.WorkItemWasAssignedToUser. I used this T-SQL select to get it:

SELECT RelationshipTypeId ,RelationshipTypeName

FROM RelationshipType

WHERE RelationshipTypeName like 'SCUtils.WorkItemWasAssignedToUser'

Then I saved it, closed the tool, and opened the management pack in the XML editor. Now I had to crossbreed Ketan’s management pack and SCUtils.ExAnalyst.WorkFlow.xml. The target was to catch “DeleteRelationship” event for “WorkItemAssignedToUser” for Incidents and ran our Powershell workflow. And then did the same for Problems, Change Requests, Service Requests, and Release Records.

I haven’t described all steps required to accomplish the goal and instead provide you with final xml file you can research if you wish.

So we had the new relationship and the workflow that created the instances of that relationship. And we came back to initial Ketan’s way for notification of the analysts but only in our case we targeted the workflow to “WorkItemWasAssignedToUser” instead of “WorkItemAssignedToUser”. I copied/pasted Ketan’s xml code into a new management pack named “SCUtils.Notification.WorkItemReAssignedTo.xml”, then made some changes in the code and added additional email templates for Problems, Change Requests, Service Requests, and Release Records. If you are going to use this solution then you have to edit those email templates because I made them as simple as possible.

To use this solution “as is” you have to have installed SMlets on the Service Manager management server and to copy RemoveAnalyst.dll in Service Manager folder (usually “C:\Program Files\Microsoft System Center 2012\Service Manager”) and then import 3 management packs:

  1. SCUtils.ExAssignedUser.Library.mp
  2. SCUtils.ExAnalyst.WorkFlow.xml
  3. SCUtils.Notification.WorkItemReAssignedTo.xml

Finally, I have to warn that you have to test any new custom solutions (including this one) in your testing environment before deploying in production. I ‘ve attached the archive file with all files I used.

How to inform ex-AssignedTo Analyst about the withdrawal.zip

Categories: System Center 2012 Service Manager

Marat Kuanyshev

Comments (12)

  • Marat Kuanyshev

    Marat Kuanyshev

    15 October 2013 at 14:58 |
    Thanks Pete!
    Now I think that it could be useful to add the support for Activities. However it's easy to realize by copy/paste method.

    reply

  • Efim Idelman

    Efim Idelman

    16 April 2014 at 01:48 |
    I tried to implement it but it doesn't seems to work. I followed the instructions above and really doesn't seems to be much if I just want to test the default, but it doesn't do anything.

    Is there a way or something I can do if it works?

    reply

  • Marat Kuanyshev

    Marat Kuanyshev

    16 April 2014 at 07:18 |
    Efim, please check that workflows work properly (Administration, Workflows, Status). If workflows fail, you have to troubleshoot that. The usual issues are:
    1. SMLEts isn't installed;
    2. For SCSM SP1 MonitoringHost.exe.config isn't configured.
    This is a good post about a workflow troubleshooting http://blogs.technet.com/b/servicemanager/archive/2009/12/21/troubleshooting-workflows-in-service-manager.aspx

    reply

  • Marat Kuanyshev

    Marat Kuanyshev

    16 April 2014 at 08:49 |
    Efim,
    I've found out that in zip file I put an old version of SCUtils.ExAnalyst.WorkFlow.xml.
    We replaced zip file. Please remove SCUtils.ExAnalyst.WorkFlow.xml from SCSM and import a new one from the archive.

    reply

  • Vishal Kalal

    Vishal Kalal

    24 June 2015 at 13:56 |
    Dear Marat,

    First of all thank you very much for the blog.

    I followed your instruction and installed in my test environment but all the workflows stopped triggering and status shows as scheduled and nothing working. After removing the 3 management packs all started working please suggest.

    Thanks.

    reply

    • Marat Kuanyshev

      Marat Kuanyshev

      24 June 2015 at 14:07 |
      Hi Vishal,
      You are always welcome!
      Please check if you have copied the dll file in SCSM installation folder. And if you have issues with workflows, sometimes the restrart of Management Service helps.

      reply

      • Vishal Kalal

        Vishal Kalal

        07 July 2015 at 17:05 |
        Hi Marat,

        Thank you very much for the clarification. Could you please confirm if this script will work with SCSM 2012 R2 and do we need to install SMLets separately on the management server.

        Thanks.

        reply

        • Marat Kuanyshev

          Marat Kuanyshev

          07 July 2015 at 17:14 |
          Hi Vishal,
          Yes, it works in R2 as well. And you do need SMlets installed on the management server.

          reply

          • Vishal

            Vishal

            08 July 2015 at 00:23 |
            Dear Marat, I tried as you suggested but didn't work. please suggest if I need to do anything else. please share your email address so I can communicate with you. Thanks

            reply

          • Vishal

            Vishal

            08 July 2015 at 00:58 |
            Hi Marat, didn't worked for me, any other suggestion.

            reply

  • Marat Kuanyshev

    Marat Kuanyshev

    08 July 2015 at 06:44 |
    Can you explain in details what exactly doesn't work?

    reply

  • Marat Kuanyshev

    Marat Kuanyshev

    08 July 2015 at 06:46 |
    Contact us using support at scutils dot com.

    reply

Leave a comment

You are commenting as guest.

This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.