在 While 循环中创建第二个任务时发生错误 - VS SharePoint 工作流程
VS 2008 中的 SharePoint 2007 顺序工作流程
存在一个问题,如果仅指定一个帐户,我的工作流程将完成,但如果指定多个用户,我的工作流程将失败并仅创建第一个任务。
在我的列表中,我有一个名为“RequiredReviewers”的必需“人员”或“组”列,其中允许在创建时选择多个用户。
我创建了一个包含以下三个活动的顺序工作流程: 1)OnWorkflowActivated:onWorkflowActivated1、workflowToken、onWorkflowActivated1_Invoked 2)WhileActivity:whileCreateTasks,(此处没有关联的令牌),代码条件:WhileTaskIsNotCompleteCondition 3) 在此期间,有一个 CreateTask 活动:createTask1、taskToken、createTask1_MethodInvoking
public sealed partial class Workflow1 : SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
public int _numRequiredReviewers = 0;
public SPFieldUserValueCollection RequiredReviewers = null;
public Dictionary<Guid, bool> TaskCompleted = new Dictionary<Guid, bool>();
public const string ApproverGroupName = "Approvers - ATC";
public SPUserCollection ApproverGroupUsers = null;
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
_numRequiredReviewers = 0;
RequiredReviewers = (SPFieldUserValueCollection)((SPItem)workflowProperties.Item)["RequiredReviewers"];
ApproverGroupUsers = workflowProperties.Web.SiteGroups[ApproverGroupName].Users;
}
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
CreateTask task = sender as CreateTask;
task.TaskId = Guid.NewGuid();
task.TaskProperties = new SPWorkflowTaskProperties();
task.TaskProperties.TaskType = 0;
task.TaskProperties.Title = string.Format("{0} - {1} - {2}", workflowProperties.List.Title, workflowProperties.Item.File.Name, RequiredReviewers[_numRequiredReviewers].User.Name);
task.TaskProperties.AssignedTo = workflowProperties.Originator;
task.TaskProperties.PercentComplete = 0F;
task.TaskProperties.SendEmailNotification = false; //default email communication;
task.TaskProperties.ExtendedProperties["User"] = workflowProperties.OriginatorUser.LoginName;
_numRequiredReviewers++;
TaskCompleted.Add(task.TaskId, false);
}
private void createTasksWhileCondition(object sender, ConditionalEventArgs e)
{
e.Result = RequiredReviewers.Count != _numRequiredReviewers;
}
}
该代码将为一个用户正确执行。
代码将导航并正确调用 createTask1_methodInvoking 函数。但是,仅创建指定的第一个用户的任务,并且工作流状态将返回“发生错误”,日志中没有任何说明或条目。 VS 没有捕获任何错误。我已经在复制器中尝试过此操作(与 while 循环相比),并且得到相同的结果(如果不是更差的结果)。
任何帮助表示赞赏。谢谢。
SharePoint 2007 Sequential Workflow in VS 2008
There is an issue wherein my workflow will complete if only one account is specified, but will fail and create only the first task if multiple users are specified.
In my list, I have a required Person or Group column called RequiredReviewers, in which multiple users are allowed to be selected upon creation.
I've created a sequential workflow with the following three Activities:
1) OnWorkflowActivated: onWorkflowActivated1, workflowToken, onWorkflowActivated1_Invoked
2) WhileActivity: whileCreateTasks, (no token associated here), Code Condition: WhileTaskIsNotCompleteCondition
3) within the while, there is one CreateTask activity: createTask1, taskToken, createTask1_MethodInvoking
public sealed partial class Workflow1 : SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
public int _numRequiredReviewers = 0;
public SPFieldUserValueCollection RequiredReviewers = null;
public Dictionary<Guid, bool> TaskCompleted = new Dictionary<Guid, bool>();
public const string ApproverGroupName = "Approvers - ATC";
public SPUserCollection ApproverGroupUsers = null;
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
_numRequiredReviewers = 0;
RequiredReviewers = (SPFieldUserValueCollection)((SPItem)workflowProperties.Item)["RequiredReviewers"];
ApproverGroupUsers = workflowProperties.Web.SiteGroups[ApproverGroupName].Users;
}
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
CreateTask task = sender as CreateTask;
task.TaskId = Guid.NewGuid();
task.TaskProperties = new SPWorkflowTaskProperties();
task.TaskProperties.TaskType = 0;
task.TaskProperties.Title = string.Format("{0} - {1} - {2}", workflowProperties.List.Title, workflowProperties.Item.File.Name, RequiredReviewers[_numRequiredReviewers].User.Name);
task.TaskProperties.AssignedTo = workflowProperties.Originator;
task.TaskProperties.PercentComplete = 0F;
task.TaskProperties.SendEmailNotification = false; //default email communication;
task.TaskProperties.ExtendedProperties["User"] = workflowProperties.OriginatorUser.LoginName;
_numRequiredReviewers++;
TaskCompleted.Add(task.TaskId, false);
}
private void createTasksWhileCondition(object sender, ConditionalEventArgs e)
{
e.Result = RequiredReviewers.Count != _numRequiredReviewers;
}
}
The code will execute appropriately for one user.
The code will navigate through, and hit the createTask1_methodInvoking function the correct number of times. However, only the task of the first user specified is created, and the workflow status will return "Error Occurred" with no explanation or entry within the logs. VS does not catch any errors. I've tried this within a replicator (versus while loop) and I get the same if not worse results.
Any help is appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将sequenceActivity 元素放入while 块中,并将“创建任务”元素放入其中。然后将“Create Task”元素的ownerActivityName 属性设置为sequenceActivity 的名称。
You should place sequenceActivity element into while block and put your "Create Task" element to it. Then set ownerActivityName property of "Create Task" element to name of sequenceActivity.