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

2008年5月11日星期日

Update Workflow Task properties with 'UpdateTask Activity'

吹水

OK~ 之前幾個post打左咁多英文, 都係時候講下廣東話啦... :p
話說我今個星期接到單非常好玩既job, 就係無人做過既 WSS/MOSS Workflow 啦~ 個期仲要鬼咁急, 不過只係做demo啫~
由於我係用 Sequential Workflow + Looping  + Create / Update / Delete Tasks, 所以出現好多問題, 最後我用左個折衷方法就係只用一個task, 靠update佢既 "Title" 同 "AssignedTo" properties 黎 "扮" 不同既 tasks. 不過最後我發覺原來要 update 一個 task 既 properties 係幾煩既....

Reference

Task reassignments using UpdateTask Activity

Overview / Steps (用返英文啦)

In order to update the task properties, 'UpdateTask' Activity should be used in VS2005 Workflow Designer. If you cannot find this in the Toolbox, try making a new Tab in Toolbox and then right-click and select "Choose Items...", then add "Microsoft.SharePoint.WorkflowActions.dll".

After 'UpdateTask' Activity is inserted, double click on it in Workflow Designer and use "UpdateTask" class to set new value for the task properties.

Code Snippet:

  113 private void updateTask1_MethodInvoking(object sender, EventArgs e)

  114         {

  115             UpdateTask task = (UpdateTask)sender;

  116             task.TaskProperties.AssignedTo = this.assignee;

  117             task.TaskProperties.Title = "Please update...";

  118         }

In the above snippet, the "AssignedTo" and "Title" properties are updated.

Key Point: Setting "AfterProperties" for "OnTaskChanged" Activity and "TaskProperties" for "UpdateTask" Activity

Very often you will find that using the method state above could not update the task properties, this is because the "OnTaskChanged.AfterProperties" and "UpdateTask.TaskProperties" are both bound to the same "SPWorkflowTaskProperties" object. So make sure that they are NOT bound to the same Properties.

I also found that if you have more that one "OnTaskChanged" Activities and "UpdateTask" Activities for a certain task, you only need two "SPWorkflowTaskProperties" objects. One for all "OnTaskChanged" Activities and the other for all "UpdateTask" Activities.

沒有留言: