1
votes

I've inherited a sharepoint workflow, but it seems to have an intermittent problem and I'm not sure where to start debugging.

User creates new item in list and saves - they can edit the item UNTIL it's approved (next step).

Admin Approve the item - trigger first workflow

Create new Task Item in relevant list

New Task Item workflow triggers automatically on Create

IF
  matching item in Copy list, send warning email and exit.
ELSE
  Create item in "Copy" list

This means that, if for some reason the Item gets approved twice, and two tasks are created (e.g. Two admins approve at the same time) then a warning email is sent to prevent both tasks being actioned.

However, just occasionally, and under circumstances I cannot work out, NO warning email is sent. Two tasks are created, the item is in the copy list, but no warning email arrives.

This happens rarely, but as these tasks relate to financial transactions, the consequences could be huge.

I've looked at the timestamps on the Tasks and Copy, and the Copy item create and first item Create are identical...with the second Task create date being a minute later. This means, as I understand it, that the second task WF should find the Copy item every time?

I've tried lots of scenarios up to having a user and two admins approve/save the item at the same time. This correctly triggered 3 workflows (new Tasks) AND generated two warning emails. I cannot work out how to get the workflow to trigger an NOT send the email warning.

Any ideas on how to break this down and debug?

Or better still, how to prevent this happening?

BTW: I am pretty new to SharePoint/SP Designer!

1

1 Answers

1
votes

From the description, it sounds as though two approvals are getting done at the same time. This is possible because it could be processing both approvals at the same time and the copy list is not yet populated with the first item so there is nothing to compare the second item with. (imagine a list getting locked whilst writing the first item, the read fior the second item would always fail).

With workflows, you can not guarantee or predict the processing time or order of events.

To get around this, I'd suggest that on approval you add something like an "approve timestamp" to the current item. Then you can prevent it getting approved twice by checking for the existence of the approve timestamp in the current item (if it exists, deny the approval).

Then you can be sure that the approval mechanism can't be fired multiple times on a single item and the rest of the task creation and copy list functions should follow suit.