locked
How to set the default value into workflow arguments and variable in re hosted workflow designer RRS feed

  • Question

  • In workflow designer I am using following code for adding arguments default value in designer but it is not reflecting there. I am able to see name and type but default value is not coming .

     ActivityBuilder builder = new ActivityBuilder();

    builder.Properties.Add(new DynamicActivityProperty { Name ="EntityName", Type = typeof(InArgument<Guid>),Value=Guid.Parse("21EC2020-3AEA-1069-A2DD-08002B30309D") });

    in the above dynamic activity property, name and type are reflected in builder but value is not reflected.

    (DocumentsHostGroup123.SelectedPane as WorkflowDesignerForm123).WorkflowDesigner.Load(builder);

     

     

     


    pramodsinghnegi
    Wednesday, July 13, 2011 9:59 AM

Answers

  • Hi Pramod,

    Your following code is wrong:

    builder.Properties.Add(new DynamicActivityProperty { Name ="EntityName", Type = typeof(InArgument<Guid>),Value=Guid.Parse("21EC2020-3AEA-1069-A2DD-08002B30309D") });

    It should be:

    builder.Properties.Add(new DynamicActivityProperty { Name ="EntityName", Type = typeof(InArgument<Guid>),
    Value= new InArgument<Guid>(Guid.Parse("21EC2020-3AEA-1069-A2DD-08002B30309D")) });

    Value should be of type InArgument<Guid>.

    Thanks,

    Tony

    • Proposed as answer by Andrew_Zhu Wednesday, August 3, 2011 8:23 AM
    • Marked as answer by Andrew_Zhu Thursday, August 4, 2011 1:28 AM
    Wednesday, August 3, 2011 8:16 AM

All replies

  • Hi,

    You can create a code workflow like this:

            public static Activity GetWF() {
                Variable<string> var =
                    new Variable<string>("var""hello workflow");
                return new Sequence {
                    Variables = { var },
                    Activities ={
                        new WriteLine{Text="Workflow Started"},
                        new WriteLine{Text=new InArgument<string>(var)},
                        new WriteLine{Text="Workflow Ended"}
                    }
                };
            }

    Then load it up in Workflow Designer. for more about create a workflow in code see:
    http://xhinker.com/post/WF4Authoring-WF4-using-imperative-code(II).aspx

    Or you can use xaml directly. after all. rehost designer will output workflow as xaml files.

    Regards

     

     


    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Wednesday, July 20, 2011 6:40 AM
    • Unmarked as answer by Pramod Singh Negi Saturday, July 30, 2011 7:31 AM
    Tuesday, July 19, 2011 6:58 AM
  • Hi Pramod,

    Your following code is wrong:

    builder.Properties.Add(new DynamicActivityProperty { Name ="EntityName", Type = typeof(InArgument<Guid>),Value=Guid.Parse("21EC2020-3AEA-1069-A2DD-08002B30309D") });

    It should be:

    builder.Properties.Add(new DynamicActivityProperty { Name ="EntityName", Type = typeof(InArgument<Guid>),
    Value= new InArgument<Guid>(Guid.Parse("21EC2020-3AEA-1069-A2DD-08002B30309D")) });

    Value should be of type InArgument<Guid>.

    Thanks,

    Tony

    • Proposed as answer by Andrew_Zhu Wednesday, August 3, 2011 8:23 AM
    • Marked as answer by Andrew_Zhu Thursday, August 4, 2011 1:28 AM
    Wednesday, August 3, 2011 8:16 AM