Accessing and Modifying a ProcessInstance
Accessing and Modifying a ProcessInstance
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.
A ProcessInstance is an individual workflow item in an Exchange store folder. You can access and modify properties of a ProcessInstance with the Fields collection of the IWorkflowSession Interface. The workflow engine automatically provides the IWorkflowSession object to the script host. For more information about the workflow engine, see Workflow Engine.
The following code demonstrates how to access a field using the field name as an index to the Fields collection on the IWorkflowSession Interface.
VBScript
Function GetFieldValue(Name) GetFieldValue = WorkflowSession.Fields(CStr(Name)).Value End Function
Using the Append method of the Fields collection, you can append new fields to a ProcessInstance, as shown in the following example:
VBScript
Sub AddFieldToItem (Name, Value) Dim FieldType FieldType = 8 ' BSTR with WorkflowSession .Fields.Append CStr(Name), FieldType, , , CStr(Value) .Fields.Update end with End Sub
You might decide to send a notification with a different subject depending on the importance flag of a ProcessInstance. You can use the Fields collection of the IWorkflowSession Interface to obtain the value for the urn:schemas:httpmail:importance property on the item. The following code shows the action script that calls shared scripts in the Workflow Designer for Exchange 2000 Server.
VBScript
' This goes in the action pane of the Workflow Designer. dim x x = GetImportance() if x=2 then 'High Importance SendMail "Alert!" else 'Normal or Low Importance SendMail "At ease." end if ' These go on the Shared Script tab. Function GetImportance() GetImportance = WorkflowSession.Fields("urn:schemas:httpmail:importance").Value End Function Sub SendMail(MySubject) Set WFMsg = WorkflowSession.GetNewWorkflowMessage() With WFMsg .From = WorkflowSession.Sender .To = GetUserMgr(WorkflowSession.Sender) .Subject = MySubject .TextBody = WorkflowSession.StateFrom & " -> " & WorkflowSession.StateTo .SendWorkflowMessage 0 'cdowfNoTracking End With End Sub Function GetUserMgr(UserAddress) with WorkflowSession mgrDN = .GetUserProperty(UserAddress, "manager", 0) '0 = cdowfUserEmailAddress GetUserMgr = .GetUserProperty(mgrDN, "mail", 1) '1 = cdowfDistinguishedName end with End Function
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.