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
Escalate to Manager
+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.
Be the first to reply!
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.