SHAREPOINT 工作流自定义任务表单(INFOPATH)之显示流程数据(第1部分)
SHAREPOINT 工作流自定义任务表单(INFOPATH)之提交发布表单(第2部分)
SHAREPOINT 工作流自定义任务表单(INFOPATH)之流程设计(第3部分)
1、继续我们的流程,在工作流上添加一个模块Forms

2、在Forms上添加现有项,找到我们发布的表单,添加

3、Sample.txt没有,可以删除

4、打开Elements.xml,添加如下三地方,最后一个为我们上一步里面的表单ID

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Workflow Name="WorkFlowLeave - Workflow1" Description="我的 SharePoint 工作流" Id="bdeb552a-4c45-4527-a893-010208563e73" CodeBesideClass="WorkFlowLeave.Workflow1.Workflow1" CodeBesideAssembly="$assemblyname$" TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"> <Categories/> <AssociationData> <Data></Data> </AssociationData> <MetaData> <AssociationCategories>List</AssociationCategories> <!-- 用于指定适用于工作流的 InfoPath 表单的标记;请删除您没有的表单所对应的标记 --> <!--<Association_FormURN>[URN FOR ASSOCIATION FORM]</Association_FormURN> <Instantiation_FormURN>[URN FOR INSTANTIATION FORM]</Instantiation_FormURN> <Task0_FormURN>[URN FOR TASK (type 0) FORM]</Task0_FormURN> <Task1_FormURN>[URN FOR TASK (type 1) FORM]</Task1_FormURN>--> <!-- 修改窗体: 为每个修改窗体创建唯一的 GUID --> <!--<Modification_[UNIQUE GUID]_FormURN>[URN FOR MODIFICATION FORM]</Modification_[UNIQUE GUID]_FormURN> <Modification_[UNIQUE GUID]_Name>[NAME OF MODIFICATION TO BE DISPLAYED AS A LINK ON WORKFLOW STATUS PAGE</Modification_[UNIQUE GUID]_Name> --> <Task1_FormURN>urn:schemas-microsoft-com:office:infopath:LeaveForm1:-myXSD-2016-01-22T05-17-45</Task1_FormURN> <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl> </MetaData> </Workflow> </Elements> |
5、设置工作流程序集、类名

程序集:Microsoft.Office.Workflow.Feature, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
类名:Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver
6、修改部署类型为ElementFile

7、新增Feature如下

1 2 3 4 | <Properties> <Property Key="GloballyAvailable" Value="true"/> <Property Key="RegisterForms" Value="Forms\*.xsn"/> </Properties> |
8、到止我们设置完成,下来添加工作流代码,TaskType就是我们的第一个表单
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | private void createTask1_MethodInvoking(object sender, EventArgs e) { //生成任务ID createTask1_TaskId1 = Guid.NewGuid(); //任务标题 createTask1_TaskProperties1.Title = "经理审批"; //设置任务操作人 createTask1_TaskProperties1.AssignedTo = @"i:0#.w|canomo\name"; //设置任务完成度 createTask1_TaskProperties1.PercentComplete = 0; //设置任务开始日期 createTask1_TaskProperties1.StartDate = DateTime.Today; //设置任务到期日期为从工作流任务开始后7天 createTask1_TaskProperties1.DueDate = DateTime.Now.AddDays(7.0); //设置任务审批权限 if (!String.IsNullOrEmpty(createTask1_TaskProperties1.AssignedTo)) { //审批人 createTask1_SpecialPermissions1.Add(this.createTask1_TaskProperties1.AssignedTo, SPRoleType.Contributor); createTask1_SpecialPermissions1.Add(@"c:0(.s|true", SPRoleType.Reader); } //设置任务表单 createTask1_TaskProperties1.TaskType = 1; SPListItem item=workflowProperties.Item; //设置任务数据 createTask1_TaskProperties1.ExtendedProperties["ows_txtTitle"] = item["Title"].ToString(); } private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e) { onTaskChanged1_AfterProperties1.PercentComplete = 1.0f; //接收审批数据 string opinion = (string)onTaskChanged1_AfterProperties1.ExtendedProperties["Opinion"]; bool approval = Convert.ToBoolean(onTaskChanged1_AfterProperties1.ExtendedProperties["State"]); SPListItem item = workflowProperties.Item; item["Opinion"] = opinion; item["State"] = approval; item.Update(); } |
9、OK,我们的工作流自定义表单就完成了,我们部署测试,如下:

