Sean Docherty -
Late night but I have not taken a hard look at the actual workflow files, but from your screenshots, it looks like the behavior you are experience is to be expected. Let me explain a bit more and then tell you what you can do.
Each branch of a state machine acts like a loop and will perform all of the actions in batch (unless told otherwise). This means, unless you tell it to move to another branch or end the state machine, it will loop indefinitely.
Now in your case, you have a state machine (State Machine 1) that has a branch in it that contains another state machine (State Machine 2). In your State Machine 2, you are properly ending your state machine (using the action), but it is ending State Machine 2. At this point, the workflow breaks out of that state machine and moves back into State Machine 1. Since there are no other actions after that, the state machine branch simply loops back through. Hence why you are seeing State Machine 2 loop again.
You need to add in an action after your State Machine 2, but within the same branch (Assigned). You can either move to another branch or end the state machine, but you need to specify something to happen or it will continue to loop.
Hope this helps!
Hello Jesse,
Thank you for the amazingly quick reply! Your reply did give me some food for thought. I undertand your point about not having and end state in the State Machine 1.
Now the questions is if I put and Change State object and set it to End State Machine would that not end the State and not send it on to the State Machine 2 that I have nested under it? See the screen shot below:
My other thought on this was, why not change it to a different state of the current State Machine or as you indicated State Machine 1.
In the first level of the State Machine, I have the following options - Pending, Approved, Rejected and More Info. I was thinking why not add another state called Finance and for the secondary approval add a Change State Machine to the bottom of the Approved branch (thus ending this branch properly) and directing it to the new branch called Finance. See the screen shot below, as we all know a picture is worth a 1000 words:
I would be interested in hearing your feedback on this.
Thank you Jesse
Sean Docherty -
You can add in the action, but move it to after the State Machine 2 but before the end of the state (Approved in State Machine 1).
As you stated, you can always add in another state to handle the logic rather than nesting the state machine, but either way it should accomplish the same results.
I am out of office today but I will see if I can take a deeper look tonight once I get back in if you still need another set of eyes.
Hope this helps!
,
Jesse McHargue has already given you enough points to ponder and may be recommendations to modify the workflow. I would emphasize on one thing, The Change State or End State machine should be the last statement in your branch. I have come across issues if there is any action after these though it is not proven to be every case. You can create as many branches in State Machine as needed to make the flow better. I also see that you have End Workflow after End State machine. If there is no actions after your Sate Machine, and the workflow is anyway ending, then you do not need this End Workflow. Hope you are able to resolve the issue.
Hello Jesse,
Thank you for getting back to me even when you are out of the office. It is appreciated.
I tried my second idea of adding another branch to the State Machine 1 called Finance and then added the Change State machine to the end of the Approved branch. After doing this I ran a test on the workflow.
The workflow ran as I thought it would and once I Approved the PO the state successfully changed to the State Machine 2 that I moved into the new Finance branch of State Machine 1. Once I received notification from the workflow I went and approved the PO as someone from Finance.
Now it did properly work through the workflow objects, but it kept repeating over and over again.
In looking at the screen shot of the workflow progress a few questions came to mind:
1. Is the State Machine object at the top level corrupted and this is why the State Machine is not working very well?
2. Is the State Machine object in the Finance branch corrupted and this is why it works through properly, but then loops again and again?
3. Is it possible for a State Machine object to become corrupted?
4. For the Assign Flexi Task object in the Finance branch does having Reminders and Escalations enabled on it cause an issue for the State Machine?
5. Should I try and turn on Safe Looping save and publish the workflow and then turn off Safe Looping and then publish the workflow?
6. Should I restart the SPTimer Service?
7. Should I restart the SPTimer Service and then do an IISRESET?
8. Would I just be better off recreating this workflow from scratch again as this workflow looks like it is corrupted beyond repair?
9. What is the best way to repair a corrupted Nintex workflow? Are there even tools out there to repair a corrupted workflow?
Jesse if you have the time to have a look and as you say "put another set of eyes on it" that would be very much appreciated.
Thank you
The reason the first state machine repeated after the sub state machine ended through the finance approval branch, is because you did not tell the state machine for >5K to change state or end, so it repeated.
In the sub state machine, you have an End State Machine step in the approved branch, this ends the sub state machine.
Now, below this state machine, in the Finance branch, you need another End State Machine to stop the 5k state machine.
See this image of your workflow. The most important piece is the new End State Machine after the Finance state machine. This will end the >5K initial state machine and prevent the loop.
And also notice that if you have the End State Machines in the correct places, you will not need the End Workflow actions as Kapil Joshi mentioned.
Best practices for state machine are:
- Do not have multiple change state actions in the same branch
- Always end a branch with a change state action, and always have the change state action at the end of the branch.
- Do not use end workflow actions in state machines
Overall I would say this is a really good workflow and you are using the state machine well. It's my most favorite action and I use it often. Great job in imagining this use case!
did a really nice job explaining it, but basically same thing is happening; once you break out of the second state machine, the first machine picks back up and since you are not telling it to go to another branch, it simply repeats.
Hello Andrew,
Thank you for your reply and the modified graphic. I was not quite sure where to place that final Change State Machine object. Your graphic helped out a lot.
provided some good advice also. I wish there was a way that you could mark more than one answer as correct on the community as I would also like to give credit to Jesse also for his invaluable assistance.
Placing that Change State Machine object where you suggested fixed the issue that I was having.
Thank you Andrew
-
I am just happy you got it working and was able to figure it out! If the advice was helpful, mark it as such for the next user!
I do not think you can mark more than once comment as the correct answer or if JIVE even supports that, but I will defer to the always amazing, JIVE Master, .
Hi Jesse,
I read your post regarding the looping of the state machine and I have something very similar and was wondering if you could help me out? I have a post on my page but here are the actions from the details history and I have screen shots of the 4 stages. When I get to the end of the state machine stage 4 it will complete and then a few minutes later I get emails from Stage 1. I am not sure what other information you might need so just let me know and I can get it for. Thanks so much I hope you can help me with this workflow.
Thanks
Wendy