分配一个Task给多人或多个群组

 

1 在Task列表中增加定制列ApprovalPersons,设置为People and Group类型,并允许多选。

2 拖放onTaskCreated动作在CreatTask之后,并在其事件中执行如下

SPList taskList = workflowProperties.TaskList;
            SPListItem taskItem = taskList.GetItemById(afterProps.TaskItemId);

            SPUser user;
            SPFieldUserValueCollection fuvc = new SPFieldUserValueCollection();

            string[] users = new string[] { "cts\\246373", "cts\\234337" };

            foreach (string loginName in users)
            {
                user = workflowProperties.Web.EnsureUser(loginName);
                fuvc.Add(new SPFieldUserValue(workflowProperties.Web, user.ID, user.Name));
            }

            taskItem["ApprovalPersons"] = fuvc;
            // note this causes onChanged event called
            taskItem.SystemUpdate(false);

posted @ 2011-07-13 13:02  风影极光  阅读(701)  评论(0编辑  收藏  举报