How to: Access Contact Data in Workflow Edit Task Forms in SharePoint Server 2010 (ECM)

Last modified: February 28, 2011

Applies to: SharePoint Server 2010

Microsoft SharePoint Foundation 2010 sends the data from workflow task forms to the workflow as a hash table, in which each key-value pair is indexed by the name of the field control on the form. For example, suppose the Contact Selector control on your form is named myUsers. In this case, you access your contact data in the hash table by specifying myUsers as the index.

This hash table can be accessed by using the ExtendedProperties property of the SPWorkflowTaskProperties object. The SPWorkflowTaskProperties object can be accessed by using the TaskProperties property of the workflow task activity for which the task from is displayed, such as CreateTask, UpdateTask, CompleteTask, or DeleteTask.

For more information about accessing workflow task data, see How to: Access Workflow Task Form Data in a Workflow in SharePoint Server 2010 (ECM).

For more information about workflow task forms, see Workflow Task Forms in SharePoint Server 2010 (ECM).

For more information about specific task activities, see the Microsoft SharePoint 2010 SDK.

To access Contact Selector control data in workflow task forms

  1. Use the Contact.ToContacts method to deserialize the hash table contact data into an array of Contact objects.

    Contacts[] contacts = Contact.ToContacts(taskProperties.ExtendedProperties["myUsers"].ToString());
    

    In this example, the name of the field bound to the Contact Selector control is "myUsers". Therefore, "myUsers" is also the index of the name-value pair in the hash table that contains the contact data.

  2. Use the various properties of the Contact objects to access the contact data.

Show: