0

I have a custom SharePoint sandboxed workflow activity that I am trying to pass an optional parameter to. However, ULS gives me the following exception message:

"SJW.SPDActivities.SendEmailWithAttachment.SendEmailWithAttachmentActivity" of type "SendEmailAttachment" failed. The method contains a parameter named "RecipientCC" but the parameters dictionary does not contain a value of this parameter.

My guess is that SPUserCodeWorkflowActionWrapper is using some sort of reflection to bind parameters to my sandboxed workflow method. However, because one of them is declared as optional in my Elements.xml file (RecipientCC), it is unable to find a value to bind and thus throws an exception.

Any idea how to get around this wonky behavior? Do I have to declare all my parameters to be mandatory?

My Elements.xml file:

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

My method declaration:

public Hashtable SendEmailAttachment(SPUserCodeWorkflowContext context,
                                     ArrayList RecipientTo,
                                     ArrayList RecipientCC,
                                     string Subject,
                                     string Body,
                                     string AttachmentListID,
                                     int AttachmentListItem)
JCardenas
  • 31
  • 7

1 Answers1

0

Try using InitialValue="something" on the Parameter node, restart IIS, remove the workflow association and add it again. Then, on your code, you must ignore the parameter value when it comes as "something"

Ricardo Peres
  • 11,795
  • 4
  • 45
  • 64