SPWorkflowActivationProperties.Item 在简单 SharePoint 工作流中为 NULL

发布于 2024-08-23 15:29:34 字数 2822 浏览 9 评论 0原文

我使用非常方便的STSDEV 工具生成了一个C# SharePoint 顺序工作流项目< /a> (它让我满足了访问 32 位 SharePoint 安装的要求,这是其他工具(例如 VSeWSS 1.3)所必需的)。

我添加了一个简单的“修改标题”操作来测试我的基本设置:

public sealed partial class CopyWorkflow : SharePointSequentialWorkflowActivity
{

    public CopyWorkflow()
    {
        InitializeComponent();
        workflowProperties = new SPWorkflowActivationProperties();
    }

    public SPWorkflowActivationProperties workflowProperties;

    private void onWorkflowActivated1_Invoked_1(object sender, ExternalDataEventArgs e)
    {
        workflowProperties.Item["Title"] = workflowProperties.Item["Title"].ToString() + ": Processed by Workflow";
        workflowProperties.Item.Update();
    }
}

无论谁通过 WSP 将我的工作流程安装到 WSS 3.0 安装中,激活该功能并配置工作流程以启动每当为特定列表创建新项目时,我都会在 onWorkflowActivated1_Invoked_1 命中中得到断点,但 workflowProperties.Item 始终为 NULL,而不是表示刚刚添加的项目的 SPListItem

当调用这个回调时,我需要做什么才能让 Item 被填充?

更新:我注意到执行工作流的线程是匿名运行的,而不是以登录用户或系统用户的身份运行,因此无法访问列表数据。此外,SharePoint 日志文件显示以下异常:

意外的 System.ArgumentNullException:值不能为 null。参数名称: uriString at System.Uri..ctor(String uriString) at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.b__0() at Microsoft.SharePoint.SPSecurity Microsoft.SharePoint.SPSecurity 处的 .CodeToRunElevatedWrapper(对象状态)。Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback) 处的 c__DisplayClass4.b__2() Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) secureCode, Object param) 在 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) 在 Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties....

Unexpected ...get_Site() 在 Microsoft.SharePoint.Workflow .SPWorkflowActivationProperties.get_Web() 位于 Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.get_Item() 位于 BechtelWorkflow.CopyWorkflow.onWorkflowActivated1_Invoked_1(对象发送者,ExternalDataEventArgs e) 位于 System.Workflow.ComponentModel.Activity.RaiseGenericEvent[T](DependencyProperty dependencyEvent,对象发送者,T e) 在 System.Workflow.Activities.HandleExternalEventActivity.RaiseEvent(Object[] args) 在 System.Workflow.Activities.HandleExternalEventActivity.Execute(ActivityExecutionContextexecutionContext) 在 System.Workflow.ComponentModel.ActivityExecutor'1.Execute(T 活动, ActivityExecutionContextexecutionContext)在System.Workflow.ComponentModel.ActivityExecutor'1.Execute(活动活动...

I have generated a C# SharePoint Sequential Workflow project using the very handy STSDEV tool (it got me around the requirement to have access to a 32-bit SharePoint installation which is required for other tools such as VSeWSS 1.3).

I've added a simple 'modify the title' action to test my basic setup:

public sealed partial class CopyWorkflow : SharePointSequentialWorkflowActivity
{

    public CopyWorkflow()
    {
        InitializeComponent();
        workflowProperties = new SPWorkflowActivationProperties();
    }

    public SPWorkflowActivationProperties workflowProperties;

    private void onWorkflowActivated1_Invoked_1(object sender, ExternalDataEventArgs e)
    {
        workflowProperties.Item["Title"] = workflowProperties.Item["Title"].ToString() + ": Processed by Workflow";
        workflowProperties.Item.Update();
    }
}

Whoever, after installing my workflow via WSP into an installation of WSS 3.0, activating the feature, and configuring the workflow to start whenever a new item is created for a particular list, I get my breakpoint in onWorkflowActivated1_Invoked_1 hit, but the workflowProperties.Item is always NULL instead of an SPListItem representing the item that was just added.

What do I need to do to get the Item to be filled when this callback is called?

Update: I've noticed that the thread executing the workflow is running anonymously rather than as the logged in user or the system user, and therefore won't have access to the list data. Furthermore, the SharePoint log file show the following exception:

Unexpected System.ArgumentNullException: Value cannot be null. Parameter name: uriString at System.Uri..ctor(String uriString) at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.<get_Site>b__0() at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state) at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties....

and

Unexpected ...get_Site() at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.get_Web() at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.get_Item() at BechtelWorkflow.CopyWorkflow.onWorkflowActivated1_Invoked_1(Object sender, ExternalDataEventArgs e) at System.Workflow.ComponentModel.Activity.RaiseGenericEvent[T](DependencyProperty dependencyEvent, Object sender, T e) at System.Workflow.Activities.HandleExternalEventActivity.RaiseEvent(Object[] args) at System.Workflow.Activities.HandleExternalEventActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor'1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor'1.Execute(Activity activi...

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

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

发布评论

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

评论(2

怪异←思 2024-08-30 15:29:34

您是否已将 WorkflowActivationProperties 与工作流程设计器绑定?

工作流程激活属性 http://img718.imageshack.us/img718/9703/ss20100305091353.png

Have you bound WorkflowActivationProperties with Workflow designer?

WorkflowActivationProperties http://img718.imageshack.us/img718/9703/ss20100305091353.png

黯然 2024-08-30 15:29:34

如果工作流属性中设计器的 InitialStateName 不等于“初始状态”或突然指向其他阶段,则会出现此问题。
一旦处于其中我们具有工作流属性等的状态,如上图所示。事情开始按要求进行。

This issue occurs if the the InitialStateName of the designer in the workflow properties is not equal to "Initial state" or is pointed to other stage abruptly.
Once a state wherein we have the workflowProperties ,etc like the above image. Things start working as required.

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