sharepointsean
Nintex Newbie

How to fire a workflow only when an item is modified

Jump to solution

Hello,

Here is my situation.

I have a list that has been created for submitting Purchase Order Requisitions. I have two different workflows against the same list.

The first workflow fires when a new PO is created and saved. Workflow number 1 does the following:

1. Checks the company name that the PO is for.

2. Creates a PO number with a certain prefix before the number depending on the company.

3. Moves to the approval process where it checks a Set Condition against a dollar value.

4. Approved or rejected by your boss. Then moves on to be approved or rejected by Accounting.

This workflow is set to start automatically and start when items are created, as seen below:

The above scenario works very well and is doing everything correctly.

The second workflow is a copy of the first workflow, but with the steps for the creation of Purchase Order number removed. I want this workflow to run if and or when someone modifies the original purchase order. I have set the workflow settings for the second (or modification workflow) as seen below:

My problem is, that when testing the creation of a new Purchase Order Requisition the first workflow fired correctly and sent out notifications and created the Purchase Order number. Part way through the first workflow process the second workflow (the modification workflow) started and sent out notifications and running through the workflow process.

Can Nintex have two or more workflows on the same list at the same time?

What is the best way to run the modification workflow so that it will only run if someone modifies the Purchase Order after it has been created?

How or what can I do to get the modification workflow to check what has been edited and depending on the edit made to the purchase order start the approval process again (as an example, if the dollar value of the Purchase Order has increased it needs to go through the approval process again)?

Any assistance is appreciated.

Thank you

0 Kudos
Reply
6 Replies
orunnals
Nintex Newbie

Re: How to fire a workflow only when an item is modified

Jump to solution

Hi Sean,

Yes Nintex can definitely do this. Here are a few suggestions:

Option 1) Instead of having two different workflows, have one single workflow that runs on create and modify and build in logic (Conditional Statements, or Switch, or IF) to have it create the PO only if the PO field hasn't been populated. For istance you could do an if statement at the beginning that checks to see if the PO field is empty and if so do your PO creation logic. This will ensure that modifications during the approval workflow don't kick off another instance, but when no approval workflow is running it will kick it off again.

Option 2) Build in logic on your update only workflow so that it checks to see if another instance is already running. This means you need to build in some updates to your created and update workflow that set a field (like a status) to denote that a workflow is in progress, and then update to complete once the workflow ends. This will allow you to then build logic to check to see the status and either begin a new approval process or end the workflow without running.

As far as tracking what field has changed and what it's changed to, that's a bit more complex. You could try using webservices to access version history and do a comparison or you could build some additional fields that store the old value and get updated by workflow once the approval completes.

Hope this helps.

Owen Runnals

Director of Professional Services - General Networks

View solution in original post

Reply
mapeacock
Nintex Newbie

Re: How to fire a workflow only when an item is modified

Jump to solution

Sean,

Further to Owen Runnals​ excellent suggestions, you can change the starting of the update workflow to be conditional and base that on some filter that would only be applicable for items where the first workflow has finished or do you envisage that both workflows would ever be running at the same time?

We would have the first workflow set a status field to dictate where it is up to along the way. Only when the status is at an appropriate stage would you allow the update workflow to run. It depends on the logic that you want to follow.

Cheers,

Mark

Reply
Not applicable

Re: How to fire a workflow only when an item is modified

Jump to solution

I'd go with a variant of the solution Owen had proposed.

Firstly, have a flag property on the list items that says whether that item has been initialised. If there's a "natural" flag (like the PO number being non-empty) use that, if not create a simple yes/no or integer field that tracks whether the item has been initialised.

If your two workflows are similar, i'd definitely go with the idea of using one workflow with a conditional "Initialise if not initialised" branch.

If the "on create" vs. "on modify" workflows end up being very different, by all means have two workflows, BUT remember if the "on create" WF writes to the item, that is a modification!, so you can easily end up with two workflows running simultanously, as you have discovered already.

If you have an "_init" flag one solution is easy. You make the start of the modified WF conditional, and make sure it will only run on a change IF the item has already been initialised. Make sure setting the _init flag is the last thing your created WF does before it exits (or at least finishes the initialisation of the item and pauses) and you should be ok.

Another approach is to have only the "modified" WF connected directly to the list (remember creating an item is a modification!), and have that WF explictly start the "created" WF if initialisation is required, and wait for that to complete before continuing.

As soon as you have multiple workflows on a list, the issues of concurrent workflows and write collisions rears its ugly head, and can make you life a misery. It's well worth designing around it from the outset.

Colin

Reply
burkslm
Nintex Newbie

Re: How to fire a workflow only when an item is modified

Jump to solution

I'd go with option 1 that Owen recommended. It is easier to maintain and troubleshoot if you only have 1 workflow running.

Reply
Not applicable

Re: How to fire a workflow only when an item is modified

Jump to solution

Hi, Sean Docherty​! Let us know how the suggestion works out! And if you can select it as a "correct answer" in this thread, please do. Thanks!

Frank

Your community manager

0 Kudos
Reply
sharepointsean
Nintex Newbie

Re: How to fire a workflow only when an item is modified

Jump to solution

Sorry for the delay on getting back to everyone regarding my post.

I would like to thank Owen and Colin for the solutions that they provided.

I would like to thank everyone for your input, as it is greatly appreciated.

Sean

0 Kudos
Reply