locked
listing available workflow variables in a custom activity GUI? RRS feed

  • Question

  • I am writing a custom activity to allow me to assign values to variables in a workflow from one of our LOB systems - this will have a GUI which allows you to type in the name of the workflow variable you wish to assign the value to. At the moment we are planning to use a text box so the user can type in the variable, but it would be really cool if I could populate a drop down list at run time with the available values in the workflow...

    ...does anyone know if this is possible? i.e. to grab a list of the variables available in the workflow that an activity has been dragged onto?
    Thursday, July 5, 2012 11:16 AM

Answers

  • Hi David,

    I think Activity tree inspection will give you the data you need .

    Activity tree inspection is used by workflow application authors to inspect the workflows hosted by the application. By using WorkflowInspectionServices, workflows can be searched for specific child activities, individual activities and their properties can be enumerated, and runtime metadata of the activities can be cached at a specific time. This topic provides an overview of WorkflowInspectionServices and how to use it to inspect an activity tree.

    The GetActivities method is used to enumerate all of the activities in the specified activity tree. GetActivities returns an enumerable that touches all activities within the tree including children, delegate handlers, variable defaults, and argument expressions. In the following example, a workflow definition is created by using a Sequence, While, ForEach, WriteLine, and expressions. After the workflow definition is created, it is invoked and then the InspectActivity method is called.

    Please check this link.

    http://msdn.microsoft.com/en-us/library/ee358719.aspx

    Thanks,

    Madhur


    MB

    • Marked as answer by LeoTang Thursday, July 12, 2012 3:13 AM
    Friday, July 6, 2012 6:02 AM

All replies

  • You can define a custom enum with all expected values and in your Activity the variable type should be the type of enum. You can use IDE to locate the custom type.


    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Regards,
    Nairs

    Thursday, July 5, 2012 11:29 AM
  • Hi Nairs,

    Thank you for your reply - not sure if I explained myself well enough - I would like to be able to view the names of the instance variables in a drop down list when the activity is dragged onto the workflow (i.e. inside the sequence activity).

    So for the example which you have, in your post; my dropdown would contain 'warehouseResponse', 'canDispatch', and 'isInvoiced' - is this possible?

    Thanks,

    David

    Thursday, July 5, 2012 1:04 PM
  • Hi David,

    I think Activity tree inspection will give you the data you need .

    Activity tree inspection is used by workflow application authors to inspect the workflows hosted by the application. By using WorkflowInspectionServices, workflows can be searched for specific child activities, individual activities and their properties can be enumerated, and runtime metadata of the activities can be cached at a specific time. This topic provides an overview of WorkflowInspectionServices and how to use it to inspect an activity tree.

    The GetActivities method is used to enumerate all of the activities in the specified activity tree. GetActivities returns an enumerable that touches all activities within the tree including children, delegate handlers, variable defaults, and argument expressions. In the following example, a workflow definition is created by using a Sequence, While, ForEach, WriteLine, and expressions. After the workflow definition is created, it is invoked and then the InspectActivity method is called.

    Please check this link.

    http://msdn.microsoft.com/en-us/library/ee358719.aspx

    Thanks,

    Madhur


    MB

    • Marked as answer by LeoTang Thursday, July 12, 2012 3:13 AM
    Friday, July 6, 2012 6:02 AM