戰地連結︰ Home My Flickr NBA.com About

2008年5月19日星期一

Adding Workflow Task Link in Auto-generated Email

Overview

Sending Email is a common activity in MOSS workflows. When alerting the task assignee to finish the task, it is quite a normal thought to include the Workflow Task Link in the Email. Below is how to do this.

Reference

Task URL in workflows..

Code Snippet

    1 private string returnTaskUrls(string taskId)

    2 {

    3     //Use this to return the relevant URL's for use in e-mail of tasks.

    4     string weburl = workflowProperties.WebUrl;

    5     string taskUrl = "/_layouts/WrkTaskIP.aspx?List=";

    6     string listId = workflowProperties.TaskListId.ToString();

    7     string fulltaskUrl = weburl + taskUrl + listId + "&ID=" + taskId;

    8     string htmlTaskLink = "<a href=" + "\"" + fulltaskUrl + "\"" + ">Click here to open the task directly in SharePoint</A>";

    9 

   10     return htmlTaskLink;

   11 }

 

Steps

The above function will return the HTML code for task link given the "taskId" parameter.

The main idea here is to get the "taskId" parameter, which is actually the "ListItemId" of the task. In order to get its value, we can bind this task properties with a variable.

  1. In your code, create a public Int32 variable
  2. Navigate to "Workflow Designer" view
  3. Right Click on the "Create Task" activity of the task you want to link, select "Properties"
  4. In properties, select "ListItemId", then clicks the ellipsis (...) button that appears
  5. Select the variable created in "Step 1" and click "OK" to bind it.
  6. Finish!

沒有留言: