Share via


Caching Custom Properties

Caching Custom Properties

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.

You can make custom properties available from one script function to the next by caching your custom properties. There are two main scenarios where this feature is useful:

  • During OnChange transitions, the workflow engine looks for matching OnExit and OnEnter rules in the ActionTable. The workflow engine evaluates the conditions and actions for each rule in a predetermined evaluation order. You can cache custom properties during the entire OnChange transition, so that they can be used by any condition or action scripts.
  • An OnChange transition from a given state, for example state A, can have many possible outcomes. Possible outcomes are state B, state C, state D, and so on. Each path from A to the respective outcome states — B, C, D, and so on — has conditions that must be tested. These conditions can contain functions that impair server performance if they are repeated too many times. After running the function one time, you can cache the result, so that subsequent condition scripts can use it without having to call the function.

Using the Properties Property of the IWorkflowSession Interface, you can cache your custom properties for the duration of one transition. In the following example, the OnExit action caches a custom property. The custom property is used in the OnChange action, the OnEnter condition, and the OnEnter action. The OnEnter action completes the transition and is the last place the cached custom property can be used.

VBScript

''''''''
' EventType: OnExit
' Condition Expression:
True
' Action Script Procedure:
Dim oItem
Set oItem = CreateObject("CDO.Item")
' Do something with oItem
WorkflowSession.Properties.Put "CustomPropertyName", oItem
''''''''
' EventType: OnChange
' Condition Expression:
   True
' Action Script Procedure
   dim MyCustomProperty
   Set MyCustomProperty = CreateObject("CDO.Item")
   Set MyCustomProperty = WorkflowSession.Properties.Get("CustomPropertyName")
   ProcedureThatUses MyCustomProperty
''''''''
' EventType: OnEnter
' Condition Expression:
   UseCustomProperty(WorkflowSession.Properties.Get("CustomPropertyName"))
' Action Script Procedure
   Dim MyCustomProperty
   Set MyCustomProperty = CreateObject("CDO.Item")
   Set MyCustomProperty = WorkflowSession.Properties.Get("CustomPropertyName")
   ProcedureThatUses MyCustomProperty
''''''''
' Shared Script:
Function UseCustomProperty(CustomPropertyValue)
   ' Do something with CustomPropertyValue.
   UseCustomProperty = True
End Function 

Sub ProcedureThatUses(varProp)
    ' Do something with varProp.
end sub

A transition may include a compensating action, which is called if your transition is aborted for any reason. However, you cannot use custom properties in a compensating action because the Properties Property is not available to compensating actions.

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.