In a Visual Studio, SharePoint 2013 workflow, the "IF" Activity provided by Microsoft can take a condition and two activities as parameters: enter image description here

I want to write a custom activity that can similarly accept other activities as parameters. In other words, delegating other activities.

EDIT: I've found that if I add a property argument of type "ActivityAction": enter image description here

The visual studio designer renders it and allows you to drop other activities into it: enter image description here

Now I just need a way to invoke that "Body" property/delegate.

Unfortunately the InvokeDelegate activity does not seem to be supported in a SharePoint workflow: enter image description here Would it be possible to write a Code Activity that replicates this functionality? Or even better, is there another way to call/execute an ActivityAction?

Here's an MSDN article that shows how to do this in a non-sharepoint workflow with Workflow Manager 1.0.


Still looking on an answer. Any updates with the Workflow Manager 1.0 refresh?

  • Can you give us an example of how you would use this? Commented Oct 22, 2013 at 21:58
  • @MonkeyWrench An example would be creating a custom activity that does something before executing another activity given to it. Example: Replicating microsoft's "IF" activity, without the compulsory Else. Notice that in microsoft's If activity, the "Then" body is one delegate, the "Else" body is another. I want to find a way to execute these delegates. Which microsoft does, after all- since the activities you place in the "Then" block are executed (albeit conditionally).
    – David
    Commented Oct 23, 2013 at 9:55
  • I'm sure this is possible, given that I got this far and that Microsoft does it. Could any SharePoint genius give this a shot? Don't be lazy, you're not going to Google your way out of this one :P
    – David
    Commented Nov 26, 2013 at 13:39
  • 2
    Wow, 8 months, two bounties. Nothing on Google. Zero answers. Man, I love SharePoint!
    – David
    Commented May 12, 2014 at 15:00
  • 1
    This will not answer your question, just heads up... The IF activity is a core Workflow Foundation (WF) thing... not a Workflow Manager activity / SharePoint activity. If you are looking to create something similar to that, I'd remove SharePoint from the equation to simplify things. Addressing the "support" part of your question, SharePoint won't care about it. SharePoint 2013 doesn't do workflow anymore, it outsources it 100% to Workflow Manager. It has no concept of what activities are installed or not in WM. Commented May 14, 2014 at 13:37

1 Answer 1


In my answer I'll be focusing on the Activity I have implemented, I will not cover how to implement custom activities. You can find additional information about development and deployment of custom activities on http://msdn.microsoft.com/en-us/library/jj193517(v=azure.10).aspx.

This is the solution I believe you are looking for:

[Designer("System.Activities.Core.Presentation.DoWhileDesigner, System.Activities.Core.Presentation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "System.ComponentModel.Design.IDesigner")]
public sealed class DelegateActivity : NativeActivity
    [DependsOn("Condition"), DefaultValue((string)null)]
    public Activity Body

    protected override void Execute(NativeActivityContext context)

Add pre-executing and post-executing logic in Execute method if that's what you need.

Now, one disclaimer... I have used DoWhileDesigner value in Designer attribute in my implementation since I didn't implement my own Designer. You could do that by inheriting from ActivityDesigner and implementing IComponentControl. You would have to provide your own XAML for the designer.

Simply drop any activity in DelegateActivity in Visual Studio and workflow will execute it. This implementation disregards Condition, so you can leave it blank: enter image description here

  • Cool. Need to try this, but is it possible to expose the "Body" as an output parameter for an existing declarative activity and then execute that body?
    – David
    Commented Nov 6, 2014 at 11:42
  • @David Could you create a new post with more details on what you're trying to accomplish with output parameter? Please let me know if my answer solves your original issue. Commented Nov 6, 2014 at 13:33
  • Made a mistake with the previous comment. If your code activity can accept the "body" parameter passed down from a declerative (non-code) activity and execute it - it solves the problem. I'll try it out and accept if it works :)
    – David
    Commented Nov 6, 2014 at 14:23
  • When you say "accept the 'body' parameter", do you mean dragging the activity from Visual Studio toolbox onto DelegateActivity? If yes, then it should work, I've tested it by dragging built-in WriteToHistory activity onto DelegateActivity. Commented Nov 6, 2014 at 14:26
  • No. Please try to understand the declarative activity part. The problem is simple: Somebody writes a declarative activity that accepts delegates. And wishes to execute said delegates. Can your code activity be used to execute those delegates, passed down as a parameter from the original declarative activity hosting your code activity? I'm thinking the answer is yes, need to try.
    – David
    Commented Nov 6, 2014 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.