Escalate to Manager

  • 10 December 2004
  • 0 replies
  • 2 views

Badge +8
Here is a code sample of escalating a workitem to current destination user's manager. Just add the code in the Escalation Action's code module. Note that i build this with K2.net 2003 Studio in SP1a, haven't tested it with previous versions.

Sub Main(ByVal K2 As EscalationActionContext)
Dim oDSH As New SourceCode.K2Utilities.DSHelper
Dim sCurrentUser As String
Dim iDest As Integer

' Loop through all destinations for current activity
For iDest = 0 To K2.ActivityInstance.Destinations.Count - 1
' Get current user
sCurrentUser = K2.ActivityInstance.Destinations.Item(iDest).User.FQN
' Get current path in AD
Dim path As String = oDSH.GetUser(sCurrentUser).Path
' Find manager
Dim oDEManager As System.DirectoryServices.DirectoryEntry = oDSH.GetManager(path)
If Not oDEManager Is Nothing Then
' Get FQN if manager was found
Dim sManager As String = oDSH.GetNetBiosNameFromDNS(oDEManager.Properties("distinguishedName")(0).ToString) & oDEManager.Properties("samAccountName")(0).ToString
If Not sManager Is Nothing Then
' Add manager as destination
K2.Destinations.Add(DestinationType.User, sManager)
End If

oDEManager.Close() ' Clean up
oDEManager = Nothing
End If
Next
' Redirect items to new users
K2.Redirect = True
End Sub

0 replies

Be the first to reply!

Reply