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
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.
- In your code, create a public Int32 variable
- Navigate to "Workflow Designer" view
- Right Click on the "Create Task" activity of the task you want to link, select "Properties"
- In properties, select "ListItemId", then clicks the ellipsis (...) button that appears
- Select the variable created in "Step 1" and click "OK" to bind it.
- Finish!
沒有留言:
發佈留言