我正在开发用于 SharePoint Designer 的自定义工作流操作,该操作将从列表中返回串联字符串。它实际上在操作内部运行良好,但总是返回错误。
测试工作流程中发生错误
在 ULS 日志中有一个空指针错误,除了我看不到在哪里。
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.WorkflowActions.SPUserCodeWorkflowActivity.ExecuteUserCode()
at Microsoft.SharePoint.WorkflowActions.SPUserCodeWorkflowActivity.System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.ActivityExecutionStatusChangedEventArgs>.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)
at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
at System.Workflow.Runtime.Scheduler.Run()
我很困惑为什么它在方法结束时返回错误。这里调用的方法
public Hashtable ListColumnToString(SPUserCodeWorkflowContext context, string ListName, string ColumnName, string Delimiter)
{
Hashtable results = new Hashtable();
try
{
using (SPSite site = new SPSite(context.CurrentWebUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[new Guid(ListName)];
string output = string.Empty;
foreach (SPItem item in list.Items)
{
output += item[ColumnName].ToString() + Delimiter;
}
results["OutputString"] = output;
SPWorkflow.CreateHistoryEvent(web,
context.WorkflowInstanceId,
0,
web.CurrentUser,
TimeSpan.Zero,
"Information",
output,
string.Empty);
}
}
}
catch (Exception ex)
{
results["OutputString"] = string.Empty;
}
return results;
}
工作流将按照我的预期正确记录输出值,并且在日志命令点,工作流操作已完成代码块,但工作流在此步骤仍报告错误。
我在 SharePoint Designer 2010 中创建工作流,它只有一个步骤,一个具有此自定义操作。如果我添加一个额外的操作,由于这个错误,它永远不会到达。
如何获得此工作流操作以返回成功?
Elements.xml - 如果它是相关的,这里是动作 XML
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<WorkflowActions>
<Action Name="List Column to String"
SandboxedFunction="true"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="ListColumnToStringActivity"
FunctionName="ListColumnToString"
AppliesTo="all"
Category="My Custom">
<RuleDesigner Sentence="From %1 list, %2 column. Save to string %3 with %4 delimiter">
<FieldBind Field="ListName" Id="1" Text="List name" DesignerType="ListNames" />
<FieldBind Field="ColumnName" Id="2" Text="Column name" DesignerType="Text" />
<FieldBind Field="OutputString" Id="3" Text="Output string" DesignerType="ParameterNames" />
<FieldBind Field="Delimiter" Id="4" Text="Delimiter for columns" DesignerType="Text" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context"
Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions"
Direction="In"
DesignerType="Hide" />
<Parameter Name="ListName"
Type="System.String, mscorelib"
Direction="In"
DesignerType="ListNames"
Description="Name of list" />
<Parameter Name="ColumnName"
Type="System.String, mscorelib"
Direction="In"
DesignerType="TextBox"
Description="Name of column" />
<Parameter Name="OutputString"
Type="System.String, mscorelib"
Direction="Out"
DesignerType="ParameterNames"
Description="Delimited string returned" />
<Parameter Name="Delimiter"
Type="System.String, mscorelib"
Direction="In"
DesignerType="TextBox"
Description="Delimiter" />
</Parameters>
</Action>
</WorkflowActions>
</Elements>
更新
经过大量查找,当我执行工作流时,我在 ULS 日志中发现了另外三个条目。我不确定如何解决这些问题,但听起来我在某处丢失了整个配置文件。
Solution Deployment : Looking for 'ReceiverAssembly' attribute in manifest root node for solution 'SharePoint.ListColumnToString.wsp'.
Solution Deployment : Looking for 'ReceiverClass' attribute in manifest root node for solution 'SharePoint.ListColumnToString.wsp'.
Solution Deployment : Missing one or more of the following attributes from the root node in solution SharePoint.ListColumnToString.wsp: assembly '', type ''.