Ask a questionAsk a question
 

AnswerGoTo Activity

Answers

  • Friday, May 05, 2006 6:56 PMSteve Danielson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    If your workflow is a State Machine workflow with multiple states, then you can have SetState activities which when executed will take the execution to the designated state. This is the closest thing to a goto.

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Monday, May 08, 2006 10:35 PMTom LakeMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    There isn't any way to create a GoTo activity in Windows Workflow Foundation.  In order for it to work the GoTo activity would need to be able to execute the other activity, followed by all other activities after it.  This is not possible because only a direct parent can execute an activity.  SetState seems to be a goto type activity but it is really just letting the parent state know who to transition to when it is done.  The other state is not transitioned to immediately, only once the state has completed.  If you have more than one SetState that runs in a state the state only transitions to the last one run, not all.

     

    If you must use a SequentialWorkflow then dynamic update would be one option.  Another possibility might be to use the ConditionedActivityGroup(CAG).  It would allow you to execute activities is varying orders.
  • Tuesday, May 09, 2006 1:55 PMSteve Danielson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Tom is absolutely correct about the way SetState functions, and that is unclear from by my description above. You would need to have some branching structure or logic in your state such that your "Goto" that is implemented by the SetState would be the last meaningful activity executed in the state. To reiterate consider this example:

    MyActivity1 - Do stuff..., go to next activity

    SetState - set to State1, go to next activity

    MyActivity2 - Do more stuff, this will still execute even though the previous activity was a SetState, go to next activity

    SetState - set to State 2 - (Last activity in state)

    All state activities complete- State transitions to State 2 and not State 1

    In your case of the Sequential workflow this is moot, and Tom's suggestion of using a looping structure is appropriate.

    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

  • Monday, July 24, 2006 2:22 PMMatt Milner - PluralsightMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Take a look at the conditionedactivitygroup for the ability to rerun a set of activities, or to decide when they should not be run.  This activity is incredibly powerful for rule driven workflows. 

    I also have a conditional sequence activity that I posted on the netfx3 site which allows you to use rules to determine if certain steps in a workflow should be executed.  http://wf.netfx3.com/files/14/control_flow/entry3469.aspx

     

    Matt

All Replies

  • Thursday, May 04, 2006 6:25 PMsenfo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    goto's are almost always a sign that there was a design error. AFAIK, there is no way to accomplish the idea of a goto in Workflow with a possible exception being the use of raising events.

    Can you provide me with more details?  I might be able to give you a better answer if I understand more about what you hope to accomplish.
  • Friday, May 05, 2006 6:56 PMSteve Danielson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    If your workflow is a State Machine workflow with multiple states, then you can have SetState activities which when executed will take the execution to the designated state. This is the closest thing to a goto.

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Monday, May 08, 2006 11:40 AMBABU_NEO Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi

    Thanks for the replies

    We are exposing Sequential workflow to the end users to create workflow dynamically.

    They are asking a feature to jump from one activity to another predecessor activity which is a feature of goto. so i am exploring the possibility of the same. I dont have the flexibility of using a state machine at this case.

    so i am looking for some solution for this problem

    Thanks

    Babu

  • Monday, May 08, 2006 9:51 PMryan.berry Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am also interested in this. We wish to allow a user to jump backwards or forwards in a workflow (this would be more done as a troubleshooting step rather than an explicit activity in the workflow). i.e. Some sort of check fails and the workflow becomes suspended. The user looks into the problem and wishes to "rewind" the workflow to an earlier step and rerun. Or wishes to skip ahead to later steps.

    Ignoring the UI issues, is something like this possible programatically? I'm looking for some way to change the workflow's work queue essentially. One solution I thought of would be to use ApplyWorkflowChanges() to change the instance appropriately (to get the execution order I want). This is not without issues however.

    Any other ideas?

    Thanks,
    Ryan
  • Monday, May 08, 2006 10:35 PMTom LakeMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    There isn't any way to create a GoTo activity in Windows Workflow Foundation.  In order for it to work the GoTo activity would need to be able to execute the other activity, followed by all other activities after it.  This is not possible because only a direct parent can execute an activity.  SetState seems to be a goto type activity but it is really just letting the parent state know who to transition to when it is done.  The other state is not transitioned to immediately, only once the state has completed.  If you have more than one SetState that runs in a state the state only transitions to the last one run, not all.

     

    If you must use a SequentialWorkflow then dynamic update would be one option.  Another possibility might be to use the ConditionedActivityGroup(CAG).  It would allow you to execute activities is varying orders.
  • Tuesday, May 09, 2006 1:55 PMSteve Danielson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Tom is absolutely correct about the way SetState functions, and that is unclear from by my description above. You would need to have some branching structure or logic in your state such that your "Goto" that is implemented by the SetState would be the last meaningful activity executed in the state. To reiterate consider this example:

    MyActivity1 - Do stuff..., go to next activity

    SetState - set to State1, go to next activity

    MyActivity2 - Do more stuff, this will still execute even though the previous activity was a SetState, go to next activity

    SetState - set to State 2 - (Last activity in state)

    All state activities complete- State transitions to State 2 and not State 1

    In your case of the Sequential workflow this is moot, and Tom's suggestion of using a looping structure is appropriate.

    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

  • Monday, July 24, 2006 7:51 AMNorman Hadfield Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    So how is it intended that we would implement a logical flow that has multiple 'feed back/forward' type loops in it that the result of a contitional branch may require a link back to activites that have already occurred but need to occur again, or skip over activities? Simple cases may be able to be 'reduced' to a 'sequential' flow but more complex ones cannot. 

    Do we have to implement a different type of workflow which sounds like a route to be avoided at all costs?

  • Monday, July 24, 2006 2:22 PMMatt Milner - PluralsightMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Take a look at the conditionedactivitygroup for the ability to rerun a set of activities, or to decide when they should not be run.  This activity is incredibly powerful for rule driven workflows. 

    I also have a conditional sequence activity that I posted on the netfx3 site which allows you to use rules to determine if certain steps in a workflow should be executed.  http://wf.netfx3.com/files/14/control_flow/entry3469.aspx

     

    Matt

  • Monday, July 24, 2006 11:59 PMNorman Hadfield Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks Matt but neither will help in the type of flow I am talking about from what I understand. I havent yet looked at the state machine capabilities and this may be a possibility although I suspect they will not be able to handle the conncurrent flow capabilities we also need since I imagine the state workflow does not support multiple simultaneous states.

    What we need is to be able to handle flow that logically is something like the following, where the feed back connections can take flow back to arbitrary (but pre-defined) places in the flow and can be intertwined.

                     ----------------------------------------------                                        ------- from somewhere else
                    V                                                        | True                             V
    -----> Activity 1   -------> Activity 2  ----> Condition 1  -- False---> Activity 3 -----> Condition 2 ---- True ---->
                                                  ^                                                                                                | False
                                                   ------------------------------------------------------------------------------

  • Tuesday, July 25, 2006 2:21 PMMatt Milner - PluralsightMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I see better what you are trying to do now.  I don't think the state machine is going to help you much either.  The problem, as I see it, is that you can't define a set of activities that logically might be repeated.  In this case, it is going to be tough to model this behavior in a workflow.  I think dynamic updates, as I believe someone mentioned, might get you what you want.  Based on the condition, you could insert steps into the workflow which would be clones of the steps you would have them go back and do. 

    Matt

  • Tuesday, July 25, 2006 10:12 PMNorman Hadfield Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I think I have come up with two possible solutions but now need to weigh up what benefits I would get from using WF with the added complexity against extending our current solution.

    Option 1: Rather than try to model the whole business process in a single flow I could break it into many workflows where each workflow only provides the logic between the real process activities, i.e after completing logical activity 1 model the flow to all possible activites that could occur next and have a WF activity that schedules each of those activities. Likewise then there is a workflow for each of those activities when they complete.

    Option 2: Merge all the separate workflows from above into a single workflow where at the top of the flow we wait on all the possible activity completion events and for each branch have the workflow from option 1. This would then be wrapped in a repeat until complete type activity. This would mean the actual workflow would look nothing like the logical process flow but that doesnt matter as its all generated anyway and never really seen by anyone.

    The only difficulty with both of these options is handling the resynchronisation of concurrent flows but I think thats possible too.

  • Wednesday, July 26, 2006 5:03 PMMatt Milner - PluralsightMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Based on your previous post, I was thinking that you would have trouble breaking the logic down into well defined blocks.  If you think you can do that, then I believe the ConditionedActivityGroup will give you the flexibility you want to run those blocks in the order you want, and as many times as you want.  It is all rules driven so you should be able to use rule logic to determine what blocks to run. 

    Matt

  • Saturday, August 12, 2006 8:33 PMkcchesnut Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Speech Server 2007 (recently delayed) has a GoToActivity.

    not sure if it's directly usable, because it uses a custom sequential workflow?

    Thanks, casey

  • Tuesday, September 05, 2006 5:56 PMPanos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    A possible solution to bypass the lack of GOTO in a SequentialWorkflow may be to use the EventHandlingScopeActivity. For a description of the technique and a sample project, you can see here.
  • Wednesday, September 06, 2006 6:39 AMMatt Lin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
  • Sunday, September 24, 2006 4:45 PMMichael Herman - Parallelspace Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    This detailed bahavior of how SetStateActivity actually works is missing from the .NET 3.0 RC1 SDK documentation.  I'll go as far as saying the documentation is misleading (as it is currently written).

    Checkout ms-help://MS.MSSDK.1033/MS.NETFX30SDK.1033/cpref36/html/T_System_Workflow_Activities_SetStateActivity.htm

    Michael.