views:

21

answers:

1

I have created a workflow using Sharepoint Designer 2007 using "Collect Data from a user" activity which has created a Task Content Type and its Edit Form (ASPX file). In this ASPX file I want to show couple of fields from the List Item on which Workflow is running; which will help the user filling in the Task Edit Form.

Is it possible within Sharepoint Designer? Can I use ListItemProperty in DataFormWebPart? How will I bind its ListItemId proerty to Workflow Item Id?

I have ASP.NET Development background; I can create a Server Control and place that in the ASPX; but i just want to sure that there is no out of box option within Sharepoint Designer before doing this..

A: 

Not sure about Designer but if you develop your custom task forms in Visual Studio you can access item properties in the code-behind class like this.

protected override void OnLoad(EventArgs ea)
{
        string listId = Request.QueryString["List"];

        SPList taskList = Web.Lists[new Guid(listId)];
        taskItem = taskList.GetItemById(Convert.ToInt32(Request.Params["ID"]));

        Guid workflowInstanceId = new Guid((string)taskItem["WorkflowInstanceID"]);
        this.workflowInstance = new SPWorkflow(Web, workflowInstanceId);

        // Document library the workflow is associated with
        itemList = workflowInstance.ParentList;
        try
        {
            // Current document
            item = itemList.GetItemById(workflowInstance.ItemId);
         }
         catch 
         {
             throw new Exception("Document associated with workflow task not found");
         } 

         string UrlToItem = string.Empty;
         string ItemName;
         if (item.File != null)
         {
             ItemName = item.File.Name;
             UrlToItem = item.File.ServerRelativeUrl;
         }
         else
         {
             ItemName = item.Title;
             UrlToItem = item.Url;
         }
//...
}
Leonidius