将工作流程令牌放入 sharepoint 中的自定义活动中

发布于 2024-08-16 08:38:58 字数 1006 浏览 4 评论 0原文

我正在尝试为我的共享点工作流程开发一个自定义活动,以简化一些事情。在其中我创建一个任务、日志、设置自定义工作流程状态 (setState) 和一些其他内容。

我遇到的问题是 setState 活动,它需要仅在主工作流程中可用的工作流令牌。我找到了以下博客文章: http ://blog.sharepoint.ch/2009/11/how-to-set-correlation-token-property.html 解释了如何创建一个属性,然后您可以将workflowToken分配给该属性并且效果很好我不知道如何将收到的令牌设置为 setState 活动?

在设计器中,看起来我不能,当我尝试以编程方式执行以下操作时:

private void setState_MethodInvoking(object sender, EventArgs e)
{
            SetState s = (SetState)sender;
            s.CorrelationToken = WorkflowToken;

}

在调用中,我收到以下错误:

This operation can not be performed at runtime.    at System.Workflow.ComponentModel.DependencyObject.SetValueCommon(DependencyProperty dependencyProperty, Object value, PropertyMetadata metadata, Boolean shouldCallSetValueOverrideIfExists) 
   at System.Workflow.ComponentModel.DependencyObject.SetValu

有什么想法吗?

I am trying to develop a custom activity for my sharepoint workflow that would simplify some things. Within it I create a task, log, set a custom workflow status (setState) and some other things.

The problem I have is with the setState activity which needs the workflowToken that is available in main workflow only. I've found the following blog post: http://blog.sharepoint.ch/2009/11/how-to-set-correlation-token-property.html that explains how to create a property that you can then assign workflowToken to and that works well, however I don't know how can I then set this token that I receive to the setState activity?

In designer it looks that I can't and when I tried to do programmatically like this:

private void setState_MethodInvoking(object sender, EventArgs e)
{
            SetState s = (SetState)sender;
            s.CorrelationToken = WorkflowToken;

}

in the invoking call I get the following error:

This operation can not be performed at runtime.    at System.Workflow.ComponentModel.DependencyObject.SetValueCommon(DependencyProperty dependencyProperty, Object value, PropertyMetadata metadata, Boolean shouldCallSetValueOverrideIfExists) 
   at System.Workflow.ComponentModel.DependencyObject.SetValu

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

难如初 2024-08-23 08:38:58

呃,我完全忽略了这样一个事实:在我链接到的文章中答案已经存在:

public CorrelationToken WorkflowCorrelationToken
{
    get { return (CorrelationToken)base.GetValue(WorkflowCorrelationTokenProperty); }
    set
    {
        base.SetValue(WorkflowCorrelationTokenProperty, value);
        **sendEmail.CorrelationToken = value;**
    }
}

在设置器中设置相关属性!那好吧!

Duh, I completely overlooked the fact that in the article I've linked to the answer is already there:

public CorrelationToken WorkflowCorrelationToken
{
    get { return (CorrelationToken)base.GetValue(WorkflowCorrelationTokenProperty); }
    set
    {
        base.SetValue(WorkflowCorrelationTokenProperty, value);
        **sendEmail.CorrelationToken = value;**
    }
}

One sets the correlation property in the setter! Oh well!

以可爱出名 2024-08-23 08:38:58

相关标记应在设计时使用属性窗口 (F4) 在 Visual Studio 中绑定。

The correlation token should be bound at design-time in visual studio, using the properties window (F4).

清君侧 2024-08-23 08:38:58

环顾四周,为您提供一些更深入的信息,并发现以下内容 回答 MS 社区论坛上的类似问题。它解释了相关令牌是什么以及如何使用它:

该活动需要具有工作流本身的相关令牌,即 onWorkflowActivated 活动的相关令牌。由于相关标记是设计时属性,因此无法在运行时设置它们,而只能在构造函数中或通过属性绑定进行设置。您可以在工作流的构造函数中设置活动的相关令牌,这是最​​简单的解决方案,但有一些缺点。
我描述了一个关于如何创建自定义活动的解决方案,该活动具有可与工作流程的相关令牌属性绑定的相关令牌属性此处

Looked around a bit more to get you some more in depth info and found the following answer to a similar question on the MS community forums. It explains what the correlationToken is and how it is used:

The activity needs to have the correlation token of the workflow itself, i.e. the correlation token of the onWorkflowActivated activity. As correlation tokens are design time properties, they cannot be set at runtime, but only in the constructor or via property binding. You can set the correlation token of the activity in the constructor of your workflow, which is the easiest solution, but has some drawbacks.
I described a solution on how to cretae a custom activity which has a correlation token property which is bindable against the correlation token property of your workflow here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文