CompensatingAction Method

CompensatingAction Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The workflow engine calls this method when a process instance transition gets aborted and the action table specifies a custom Component Object Model (COM) object as the compensating action. The custom COM object must implement this method.

Applies To

ICustomActivity Interface

Type Library

Microsoft CDO Workflow Objects for Microsoft Exchange

DLL Implemented In

CDOWF.DLL

Syntax

[Visual Basic]Function CompensatingAction
(
    pSession As WorkflowSession
)

[C++]HRESULT CompensatingAction (     IWorkflowSession pSession );

Parameters

  • pSession

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

When your action table includes the programmatic identifier (PROGID) of a custom COM object as a compensating action, the workflow engine creates an instance of your COM object and calls the CompensatingAction method that your COM object has implemented. COM objects can only be created in privileged-mode workflows, so the engine checks whether this ProcessInstance belongs to a privileged-mode workflow. For more information, see the Mode Property.

Examples

To use this interface, you need to create your own COM object. If you implemented the following code in a dynamic-link library (DLL) and used the PROGID of your DLL in the CompensatingAction field of a row in your workflow action table, when the workflow engine used that row the following CompensatingAction would execute for an aborted ProcessInstance transition:

  • Send a message from the workflow user to the workflow user with the subject Compensating Action and the following text: <currentstate> -> <newstate>.

[Visual Basic]

Implements CDOWF.ICustomActivity

Sub SendMail(MySubject, ByVal pSession As CDOWF.IWorkflowSession)

Set MyMsg = CreateObject("CDO.Message")
With MyMsg
   .From = pSession.Sender
   .To = "someone@example.com"
   .Subject = MySubject
   .TextBody = pSession.StateFrom &amp; " -&gt; " &amp; pSession.StateTo
   .Send
End With

End Sub

Sub ICustomActivity_CompensatingAction(ByVal pSession As CDOWF.IWorkflowSession)

SendMail "Compensating Action", pSession

End Sub

Function ICustomActivity_EvaluateCondition(ByVal pSession As CDOWF.IWorkflowSession) As Boolean

ICustomActivity_EvaluateCondition = True

End Function

Sub ICustomActivity_ExecuteAction(ByVal pSession As CDOWF.IWorkflowSession)

End Sub

See Also

ProcessInstance CoClass

Mode Property

ICustomActivity Interface

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.