Vadim Tabakman

The Nintex Workflow State Machine is a very useful piece of functionality. Not only is it a great enhancement to workflow design, it also improves maintenance of a workflow in the future.

Your workflow logic may require you to jump between difference levels business logic. An example of this, is if you have several levels of synchronous approvals. Having Request Approval actions one after the other is one option. But one of your requirements may be, that if the 2nd level approval rejects an approval, that it then goes back to the previous level of approval.

You could build the logic using the Loop action, but it would be messy and later on, it would be hard to maintain.

Problem

I have 3 levels of approval. At the first level, if the approval is rejected, I want the initiator notified and the workflow to end. If they approve, then I want the workflow to continue to the 2nd level approval. If the 2nd level approval is rejected, it should go back to the 1st level approval. The 3rd level approval, if rejected, should go back to the 2nd level approval.

Solution

Create a new workflow, and add a State Machine action to it.



By default, the State Machine will have 2 states named "State 1" and "State 2". a State Machine MUST have atleast 2 states.



As we are looking at a solution that will have 3 levels of approvals, you need to first open the configuration of the State Machine. Here, you can update state names and add new states.



If you then go into the configuration window for the State Machine, you need to select the Initial State. This is the first state of the State Machine that the workflow will go into.



For the 1st approval level state, we send out an approval via the Request Approval. If the approver, which I have set as the initiator just for testing, approves the task, then we use the Change State action to change to the 2nd Level Approval state.



If they reject the task, then we use a Send Notification action to notify the Initiator, and then we add a Change State action to change to "End State Machine".



The Level 1 Approval state looks like this :


This is the beginning of our state machine. Now we build the logic for the other 2 levels of approval. The Level 2 Approval state simply sends another Request Approval and if it's approved, changes state to Level 3 Approval state, and if rejected, it changes state back to Level 1 Approval state.



Advanced Information

Changing states only occurs at the end of the current state.

This is a very important piece of information. This means, that if you have a Change State action, followed by other actions, those actions will execute before any state change.



Above, I have added a Query List action, a For Each action and a Log in the History List, all after the Change State action that changes to the Level 2 Approval state. even though the Change State action is above those action, behind the scenes, it simply sets a flag to tell the workflow that at the end of the current state, we want to jump to the Level 2 Approval state.

I wanted to mention this, in case anyone finds themselves in a situation where they think the state change should happen instantly, it won't. It will only happen at the end of the current state.

Important Downloads

Download State Machine Workflow

Posted by Vadim Tabakman Monday, February 6, 2012 7:03:00 PM Categories: Change State Nintex Nintex Workflow Send Notification State Machine
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Wednesday, May 16, 2012 10:19:04 PM
DaveLev

re: Nintex Workflow - State Machine

Great background on State Machines, Vadim, thank you.

Tuesday, July 24, 2012 11:34:34 AM
Yureimacv

re: Nintex Workflow - State Machine

Great, excellent tutorial. Laughing

Tuesday, July 24, 2012 3:16:51 PM

re: Nintex Workflow - State Machine

Hi Yureimacv,

thanks.  If you have something you're not sure about and think it'd make for an interest post, let me know.

cheers,

Vadim

Sunday, December 23, 2012 3:11:11 PM
unknown

re: Nintex Workflow - State Machine

great ex. thanks

Sunday, December 23, 2012 3:11:46 PM

re: Nintex Workflow - State Machine

You're welcome Mr Unknown :).

Tuesday, January 15, 2013 2:07:19 PM
Richard Twigg

re: Nintex Workflow - State Machine

Thanks Vadim.  Could I use this for an ACCEPT, REJECT, REQUEST CHANGES scenario?  If rejected, the workflow ends, if accepted the workflow continues, if changes are requested I would like an e-mail to go back to the initiator (and the other 2 approvers, all 3 must approve to move on) for changesOnce changes are made I would like it to go back to the 3 approvers.  I hope that makes sense.  Thanks

Friday, February 22, 2013 2:37:20 AM
Yudha

re: Nintex Workflow - State Machine

Hi Vadim,


I have a problem looks like this. So my scenario :

1. User can initiate approvers as many as he want

2. Approval scenario just like yours. If the next approver reject it, workflow will back to current approver (not back to the first approver). So the differences between your scenario and mine is in your scenario there is a 3 level approval, whereas in my scenario, there is invinite level approval. I confuse how to separate list of approvers who have approved and who will be the next.

Can you give me an advice? I really appreciate it.

Thanks

Friday, February 22, 2013 7:02:16 AM

re: Nintex Workflow - State Machine

Hi Yudha,

I'd definitely do this in a State Machine.  It would be the easiest way to do it and also later on, it's be easier to maintain.

You can have a state for each scenario you mentioned and have the workflow jump between states, depending on what outcome approvers selected.

cheers,

Vadim

Monday, April 8, 2013 8:23:06 AM
praveen

re: Nintex Workflow - State Machine

Hi Vadim,
Requirement:
At each state user will be specifying the next approver and select certain values using Custom flexi task form.
1. How we can collect next approver using flexi task form
2. How we can hold the selected properties or condition using flexi task form

Drop me your email so i can send more details.

Thanks,

Praveen

 

Monday, April 8, 2013 8:25:14 AM
praveen

re: Nintex Workflow - State Machine

mailpravinat@gmaildotcom

Friday, April 11, 2014 9:41:50 AM
priti desai
Gravatar

re: Nintex Workflow - State Machine

Hi 

Is there another way to implement this without having use of state machine.. for eg for mine the statemachien is takign 5 min to get executed

Thansk

 

Friday, April 11, 2014 10:09:16 AM

re: Nintex Workflow - State Machine

Hi Priti desai,

the delay you are seeing is because of Nintex Workflows setting called Safe Looping.  This is enabled in Central Admin > Nintex Workflow Management > Global Settings.

It is on by default, to prevent users from designing workflows with infinite loops that will affect the performance of the server.

Safe Looping puts in a hidden delay into each iteration of a Loop action and also with each Change State action in a State Machine.

cheers,

Vadim

Wednesday, August 20, 2014 12:15:54 AM
Akash Anand
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

        Thanks for Sharing 3 levels of approval State Machine Nintex Workflow. Excellent  example....

 

Thanks

Akash

Wednesday, August 20, 2014 8:03:24 AM

re: Nintex Workflow - State Machine

Hi Akash,

glad it helped you.

cheers,

Vadim

Tuesday, June 9, 2015 4:00:59 AM
Daniel
Gravatar

re: Nintex Workflow - State Machine

Changing states only occurs at the end of the current state.

 

This is a very important piece of information. This means, that if you have a Change State action, followed by other actions, those actions will execute before any state change.

This helped me A LOT. Thanks for that hint!

Thursday, October 15, 2015 4:03:55 AM
shardul Pasare
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

             I am using state machine approval process for one document library. It create tasks for every approval in custom task list. It is found that old approved tasks gets deleted after few days. Is it any nintex behavior? can we avoid this.

            also I have one more observation - I have used some approval process in some other workflow (not state machine) . It also creates tasks in separate custom list. but for this task list all older tasks are present.

           so for one task list items got deleted and from other it is not.

            Can  you please help regarding this. Thank you in advance.

 

Thanks and regards,

Shardul Pasare

 

 

Thursday, October 15, 2015 9:52:31 AM

re: Nintex Workflow - State Machine

H Shardul,

that is default SP behavior.  It has a Workflow Auto Cleanup job that cleans up tasks, older that 60 days that are complete.

You'd need to work with that timer job to change that.

cheers,

Vadim

Friday, October 16, 2015 1:38:14 AM
Shardul Pasare
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

               Thank you so much.

               But the problem here is that if its SP behavior then it should be same for all task list. But it is not same. Below are my two scenarios

               1) Task items got deleted in below scenario

                           I am using state machine approval process for one document library. It create tasks for every approval in custom task list. After 3 approvals document gets copied from this library to another. and  item gets deleted from current library. In this case we observed that older tasks(more that month) got deleted.

                2) Tasks not deleted from task list in below scenario

                          I am using simple one level approval process for one document library. It create task for approval in custom task list. After this approval document directly moves from this library to another library. In this case we observed that older tasks(almost for 7 to 8 months) are still present

              Also task lists are same. So what might be reason behind this... as from one task list items deleted and from other not deleted. its SP behaviors then it should be same for  all tasks. but it is not the case.

              Can you please help on this.

 

Thanks and regards,

Shardul Paare

Friday, October 16, 2015 4:43:21 PM

re: Nintex Workflow - State Machine

Hi Shardul,

how are you "moving" the document in the 2nd scenario?

Vadim

Monday, October 19, 2015 12:43:32 AM
Shardul Pasare
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

          For second scenario, we are moving document with custom workflow activity which is internally using SPFile.MoveTo function.

Thanks and regards,

Shardul Pasare

Monday, October 19, 2015 4:23:39 AM
shardul Pasare
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

             In first scenario, we are copying and deleting document from source library. And in second scenario we are directly moving document from source library. So is there any relation with task deletion(created by source document)?

            Also one more observation, deleted tasks are not present in recycle bin as well.

Thanks and regards,

Shardul Pasare

Sunday, November 1, 2015 11:03:00 PM
shardul Pasare
Gravatar

re: Nintex Workflow - State Machine

Hi Vadim,

               Can you please let me know if you have any inputs for this issue.

Thanks and regards,

Shardul Pasare

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (279)
  • Comments (1769)

Categories