分类: 系统运维
2010-05-29 16:17:13
When you create a workflow task, its property data comes from an object, which you can access through the property of the activity. This object contains information that is standard for every workflow task, as well as any custom properties contained in the task schema. By initializing the object variable you specify for the property, you can use the task data passed to the workflow.
Note |
---|
The object you access through the property simply contains initialization information about the newly created task; it is not dynamically bound to the task itself in any way. Changes made to the task are not reflected in the data stored in this object. |
The object contains a standard set of properties for every workflow task in SharePoint Foundation, such including , , , and .
In addition, the object also contains a hash table, represented by the property, to store custom task properties. You can access a specific custom property by passing the property name as an index for the property.
Microsoft SharePoint Server 2010 names each custom data value in the hash table after the task field that contains the data. For example, if you have a text field in your workflow task named comments, the index name of that field's data in the property hash table is comments as well.
Note |
---|
The hash table is populated with both standard fields and custom fields. However, the standard workflow task type fields are represented with GUID indexes, rather than with their names, to prevent possible name collisions with custom fields of the same name. We recommend you access standard workflow task fields through their respective properties, rather than through the hash table. |
In general, bind the property of each task-related activity to the object variable you defined for the property of the activity that created that specific task. This object variable is used as a conduit to pass data into the task.
For more information about setting activity properties, see the Windows Workflow Foundation SDK.
Data from a Microsoft InfoPath 2010 workflow task form is not passed directly into the workflow, as it is for workflow association or initiation forms. Rather, the task form changes the fields corresponding to the form schema in the task item directly; these changes are passed into the workflow only if the workflow is waiting for an event. To receive data from an InfoPath form, you need an event receiver activity for the corresponding event, such as . The object bound to the property of the object stores the fields in the task that have changed (and only those that have changed). By default, an InfoPath form will alter the task using fields that match the form's schema.
If the data is from a standard workflow task field, access it by using the applicable property of the object.
For example, suppose you set the property of the activity for your workflow task to an object variable named wfTaskProps. To access the property, you refer to it in your code as follows:
wfTaskProps.AssignedTo.ToString()
If the data is from a custom field, access it by using the field name as the index value for the property of the object.
For example, to access a custom property named comments, refer to it in your code as follows:
wfTaskProps.ExtendedProperties("comments").ToString()