State Machine does not end state & jumps to the paralle state machine

  • 16 February 2017
  • 8 replies
  • 34 views

Badge +1

Hello all,

I have a question about state machine application. I have used several state machines for a parallel workflow as in the attachment. I request a data from different team members then approval process starts and if approval is done i presumed that process will end for all of the each state machine workflows (state machine1,2,3...)

But as you can see in the attachment when first state machine ends it jumps to the state machine2 approve2 side. I would expect the process should stop for each state machine when it comes to end state machine box.

How can i prevent this?

Using several state machine should not be big deal i guess?


8 replies

Userlevel 7
Badge +17

Maybe if you're using parallel branches you should define a boolean variable (in parallel branch action configuration) that when set to true (ex. your approval ends in one state machine) goes out of the block?

Regards,

Tomasz

Userlevel 6
Badge +12

Hello Deniz Boyaci‌ - 

First off, welcome to the community! I see that this is one of your first few questions and I hope that we can get things cleared up and get you on the right path with your workflow.

I want to point you to a great place within the community, the Learning Center. There are a ton of great examples and tutorials on a wide variety of topics regarding Nintex products. One in particular is about the State Machine by Mike FitzmauriceUsing State Machines and Loops in Your Nintex Workflows.

Ok, so now on to why you really came...to get some help, insight, and some answers!

First and foremost, your workflow is working as depicted in your screenshot. You have multiple State Machines all running in parallel. They are independent of each other. When you end State Machine 1, it does not jump to State Machine 2 because it is already running in parallel. State Machine 2 may end before State Machine 1 or 3 or may be still awaiting approval. Because you have these within a parallel action, all actions must complete before the workflow moves forward. This means that your workflow will continue to wait for the other state machines to end before all coming out of the parallel action.

I request a data from different team members then approval process starts and if approval is done i presumed that process will end for all of the each state machine workflows (state machine1,2,3...)

When a State Machine is ended, it is only ending the one specified within. You cannot have State Machine 2 end State Machine 1 and 3 if they are still running. Again, since they are within a parallel action, the remaining state machines will continue to run until they hit their own end workflow action.

If you are looking to end all other running state machines once one user or group provides an approval, you would need to change your approach. Let us know what you had in mind and if this helps or if you need some help with how to set that up.

Badge +7

Hello Deniz Boyaci‌,

Welcome and I hope I can help you out here. First Jesse McHargue‌ has a couple of good points for you in his reply.

Such as, you cannot have a State Machine end another State Machine.

Jesse has some very good responses and articles on the Nintex Community, so if you have a chance have a look at some of his other postings.

I have had to create a Purchase Order Requisition workflow and when creating this workflow I also used lots of State Machines. Here are the links to a couple of questions that I have posted about State Machines:

Help My State Machine is Looping

The above question helped me as I did not have an End State Machine action in the proper place and it caused my State Machine to loop and send out over 3K emails.

Using Switch Action in State Machine

In this question I was trying to use a Switch Action to evaluate a value in a field. I ended up using Conditions instead and it made it more reliable.

One thing that you could also try is to break the different State Machines into smaller workflows and when the first State Machine approval completes it then goes on to call the second State Machine approval workflow and so on. Please see the image below:

I have also noticed that you are using the Request Approval action. Would the Assign Flexi Task Action not give you more flexibility?

As an example I will reference the Purchase Order requisition workflow that I have created. This might provide some food for thought on designing your approval process differently.

Recently I had to redesign my PO workflow as I had some new items to add into the workflow. I took my original very large workflow and broke it down into one smaller main workflow and 5 other specific workflows.

A couple of advantages of doing this is that it makes the workflows run faster and if one part of the workflow "breaks" it does not take down the secondary workflow.

(I would read Aaron Labiosa‌ article Defensive Workflow Design Part 3 Seperation of Concerns as this article gives some very good information about dividing a large workflow and some of the benefits of doing this.)

The way that I did this is that I created my other workflows and used the Start Workflow action to call the other workflows. As seen above in my State Machine, in item 1 if the PO is Approved I change the state to the Finance state. But in the Finance State I am calling the Finance workflow that I have through the Start Workflow action.

In item 2 I am using an End Workflow action to stop the current workflow. I originally tried the Change State action and setting it to End State Machine, but this did not work well. It ended the State Machine but continued through the rest of the workflow.

I have attached the PO workflow that I have created to this post in case you want to review it in order to give yourself a different perspective on how to design your workflow with State Machines.

Good Luck

Badge +1

Hello Jesse,

According to your comment

"They are independent of each other. When you end State Machine 1, it does not jump to State Machine 2 because it is already running in parallel. State Machine 2 may end before State Machine 1 or 3 or may be still awaiting approval. "

That is not the case i observe in my workflow. Please find the below picture. In thi picture, you can see that State Machine2 & State Machine3 start to loop while State machine1 is still wating data.

 

flow

Userlevel 7
Badge +17

Deniz, I think this is exactly your case. Or I'm missing something. You have three independent branches in "Parallel Block" action each having its own State Machine. The first is waiting for the feedback from approver, so it is on hold. Second and third ones had already been given feedback by approvers so they moved on. I see nothing in contradiction to what Jesse wrote. What you are showing is the exact, independent behavior of each branch and each state machine within.

Again - if in such approach you want to terminate the whole "Parallel Block" action after the first state machine is ended create a boolean variable that you will use as a rule to terminate parallel action once its value is true:

Regards,

Tomasz

Badge +1

Sorry for the confusion, i want to clarify it more clearly. The problem is for the state machine2 branch is following.

Steps are like that;

1Vehicle NVH Request Data

2) Approval is asked

3) Approver approves the data

4) Vehicle NVH Request Data again ( which i do not want). I want the state machine to hold the process at step3 until all of the parallell approvals are finished.

 

By the way, thanks for your valuable feedbacks and examples that you have shared. I am currently investigating them as well.

Userlevel 6
Badge +12

Hello - 

Based on your design, you should be able to do what you are looking to accomplish.

I want the state machine to hold the process at step3 until all of the parallell approvals are finished.

I recreated your workflow (from what I can see that you provided), and I am unable to recreate the issues that you are describing. However, I did see some strange behavior when I was creating the WF and copying/pasting WF actions from one branch into another.

Not sure if you copied/pasted anything, but that may be a lingering issue. I also added some Log actions to my workflow to see when the workflow jumps from one state to the next, as well as when each state machine is started. I did not see anything out of place in the logs for me.

199621_pastedImage_3.png

Note that I created only the parallel action with all the state machines (ignore the action set actions, they are empty. I use them for testing purposes). If you would like, I can take a look at your wf if you would like (are able) to share it. Not sure what else is going on before/after this section within your workflow.  

I would suggest that you add log actions and do some test runs to see if you can pinpoint the issue. Another option, and is usually a last resort, is to recreate the workflow from the start on another list/site and see if the issues persists.

Userlevel 7
Badge +17

4) Vehicle NVH Request Data again ( which i do not want). I want the state machine to hold the process at step3 until all of the parallell approvals are finished.

Deniz, as we have already underlined that, you cannot make any impact from one state machine onto another using OOTB actions. However you can do it using ex. a field in the item properties, on which the workflow runs. You can put there a value which will be verified by other state machines and based on it they will behave adequately.

For example, you can have a text field with a value 000 (binary). Once a specific branch is completed, it just updates corresponding 0 with 1. So when the left state machine is finished you will have 100. If right: 101. So before you go into "End State Machine" state, you update corresponding number in the string and then verifies whether its value is already 111 or not. You can as well use "Wait for field change" action (however it is not recommended), to pause your workflow until the value is 111.

I hope it will help you happy.png

Regards,

Tomasz

Reply