0

我有一个自定义的 SharePoint 沙盒工作流活动,我试图将一个可选参数传递给它。但是,ULS 给了我以下异常消息:

“SendEmailAttachment”类型的“SJW.SPDActivities.SendEmailWithAttachment.SendEmailWithAttachmentActivity”失败。该方法包含一个名为“RecipientCC”的参数,但参数字典不包含此参数的值。

我的猜测是 SPUserCodeWorkflowActionWrapper 正在使用某种反射将参数绑定到我的沙盒工作流方法。但是,因为其中一个在我的 Elements.xml 文件 (RecipientCC) 中被声明为可选,所以它无法找到要绑定的值,因此会引发异常。

知道如何解决这种不稳定的行为吗?我是否必须声明我的所有参数都是强制性的?

我的 Elements.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <WorkflowActions>
    <Action Name="Send an Email with an Attachment"
            SandboxedFunction="true"
            Assembly="$SharePoint.Project.AssemblyFullName$"
            ClassName="SJW.SPDActivities.SendEmailWithAttachment.SendEmailWithAttachmentActivity"
            FunctionName="SendEmailAttachment"
            AppliesTo="all"
            Category="SJW Custom Actions">
      <RuleDesigner Sentence="Email %1 with attachment %2">
        <FieldBind Field="RecipientTo,RecipientCC,Subject,Body" Text="these people" Id="1" DesignerType="Email"/>
        <FieldBind Field="AttachmentListID,AttachmentListItem" Text="file" Id="2" DesignerType="ChooseDoclibItem"/>
      </RuleDesigner>
      <Parameters>
        <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In" DesignerType="Hide"/>
        <Parameter Name="RecipientTo" Type="System.Collections.ArrayList, mscorlib" Direction="In"/>
        <Parameter Name="RecipientCC" Type="System.Collections.ArrayList, mscorlib" Direction="Optional"/>
        <Parameter Name="Subject" Type="System.String, mscorlib" Direction="In"/>
        <Parameter Name="Body" Type="System.String, mscorlib" Direction="In"/>
        <Parameter Name="AttachmentListID" Type="System.String, mscorlib" Direction="In"/>
        <Parameter Name="AttachmentListItem" Type="System.Int32, mscorlib" Direction="In"/>
      </Parameters>
    </Action>
  </WorkflowActions>
</Elements>

我的方法声明:

public Hashtable SendEmailAttachment(SPUserCodeWorkflowContext context,
                                     ArrayList RecipientTo,
                                     ArrayList RecipientCC,
                                     string Subject,
                                     string Body,
                                     string AttachmentListID,
                                     int AttachmentListItem)
4

1 回答 1

0

尝试在 Parameter 节点上使用 InitialValue="something",重新启动 IIS,删除工作流关联并重新添加。然后,在您的代码中,当它作为“某物”出现时,您必须忽略参数值

于 2012-12-01T17:36:45.973 回答