locked
Required Argument for Contained Activity RRS feed

  • Question

  • Hi Everybody,

    when i define a Activity with a required InArgument then passing the Argument is trivial, while the Activity stays the Root Activity:

    ActivityWithRequiredArgument act = new ActivityWithRequiredArgument ();
    
    Dictionary<string, object> dict = new Dictionary<string, object>();
    
    dict.Add("myRequiredArgumentDescriptor", myRequiredArgumentInstance);
    
    WorkflowInvoker invoker = new WorkflowInvoker ();
    invoker.Invoke(act, dict);
    
    

    How do i pass the required Argument into an Activity which is not the root Activity, for example:

    Sequence seq = new Sequence() { Activities = { new ActivityWithRequiredArgument(); }; };
    Dictionary<string, object> dict = new Dictionary<string,object>();
    dict.Add("myrequiredArgumentDescriptor", myRequiredArgumentInstance);
    WorkflowInvoker invoker = new WokflowInvoker();invoker.Invoke(seq,dict);

    doesnt work, because Sequence doesnt require the Argument, but ActivityWithRequiredArgument does.

    Tuesday, April 5, 2011 10:24 AM

Answers

  • You would need to bind the argument of the inner activity to the argument of the root activity, or else bind the inner argument to a workflow variable that is bound to the root activity's argument.

    If you are constructing these workflows in code, then you could use a DynamicActivity as your outer activity so that you could specify that the root activity has your required argument. This topic has an example of a DynamicActivity with arguments defined, and values are passed in when the workflow is invoked, and these values are used by inner activities. http://msdn.microsoft.com/en-us/library/ee358749.aspx

    Does that give an example of the sort of thing you are trying to do?

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    • Marked as answer by AlexMichael Tuesday, April 5, 2011 3:15 PM
    Tuesday, April 5, 2011 12:15 PM

All replies

  • You would need to bind the argument of the inner activity to the argument of the root activity, or else bind the inner argument to a workflow variable that is bound to the root activity's argument.

    If you are constructing these workflows in code, then you could use a DynamicActivity as your outer activity so that you could specify that the root activity has your required argument. This topic has an example of a DynamicActivity with arguments defined, and values are passed in when the workflow is invoked, and these values are used by inner activities. http://msdn.microsoft.com/en-us/library/ee358749.aspx

    Does that give an example of the sort of thing you are trying to do?

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    • Marked as answer by AlexMichael Tuesday, April 5, 2011 3:15 PM
    Tuesday, April 5, 2011 12:15 PM
  • Hi Steve,

    thanks for the answer. The first sentence of your answer is the solution of my problem. Ill bind the required Argument of the inner Activity to a variable that belongs to the outer(parent) Activity.

    Thanks alot,

    Greetings Alex

    Tuesday, April 5, 2011 3:15 PM