Sharepoint顺序工作流不将任务添加到任务列表中

时间:2013-04-01 03:47:30

标签: c# sharepoint workflow

将工作流部署到sharepoint站点后,我可以通过创建列表的新行来启动工作流。这些也反映在该领域,“正在进行的工作流程”。但是,我似乎无法在“任务”列表中找到为特定用户创建的任务。

作为Sharepoint开发的初学者,我不确定是什么问题。请劝告。

1 个答案:

答案 0 :(得分:0)

这是我测试过的代码:

    private void OnCreateTask_MethodInvoking(object sender, EventArgs e)
    {
        taskId1 = Guid.NewGuid();
        //   SPContentTypeId myContentTypeId=new SPContentTypeId("0x01080100e73fd5f172cb40d8a5dca97fad7a58b8");
        SPContentType myContentType = SPContext.Current.Web.ContentTypes["Powerfull Approval Workflow Task"];
        CreateTaskApproval_ContentTypeID = myContentType.Id.ToString();
        #region Enable ContentTypes
        if (this.workflowProperties.TaskList.ContentTypesEnabled != true)
        {
            workflowProperties.TaskList.ContentTypesEnabled = true;
        }
        bool contenTypeExists = false;
        foreach (SPContentType contentType in workflowProperties.TaskList.ContentTypes)
        {
            if (contentType.Name == myContentType.Name)
            {
                contenTypeExists = true;
                break;
            }
        }
        if (contenTypeExists != true)
        {
            workflowProperties.TaskList.ContentTypes.Add(myContentType);
        }
        myContentType.EditFormUrl = "_layouts/SequentialWorkflow/TaskEdit/TaskEditForm.aspx";
        myContentType.DisplayFormUrl = "_layouts/SequentialWorkflow/TaskEdit/TaskEditForm.aspx";
        myContentType.Update();
        #endregion
        taskProperties.PercentComplete = (float)0.0;
        taskProperties.AssignedTo = myInstantiationData.User;
        taskProperties.DueDate = myInstantiationData.DueDate;
        taskProperties.Description = myInstantiationData.Request;
        taskProperties.StartDate = DateTime.Now;
        taskProperties.Title = "Please approve " + this.workflowProperties.Item.DisplayName;
    }