我正在尝试将可选参数传递给自定义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)
答案 0 :(得分:0)
尝试在Parameter节点上使用InitialValue =“something”,重新启动IIS,删除工作流关联并再次添加。然后,在您的代码上,您必须忽略参数值作为“某事”