SPWorkflowActivationProperties.Item is NULL in Simple SharePoint Workflow

我只是一个虾纸丫 提交于 2019-12-10 15:29:53

问题


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...


回答1:


Have you bound WorkflowActivationProperties with Workflow designer?

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




回答2:


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.



来源:https://stackoverflow.com/questions/2381327/spworkflowactivationproperties-item-is-null-in-simple-sharepoint-workflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!