0

I'm creating a Document Library on Office 365.

I've created a Workflow for a Document Library which gets triggered on creating a new Document within the Library.

I've also created a separate Workflow that will get triggered when an existing Document is modified in some way.

Problem is - if someone creates a new Document, both Workflows run. It also seems that when modifying a document for the 2nd time, the modify workflow doesn't execute again.

Is there anyway around this?

EDIT:

I still can't seem to get this working, my statement looks such like:

If Current Item:Created equals Current Item:Modified (do nothing) else (Email PersonA). 

The Transition to stage contains "Go to End of Workflow"

EDIT 2:

enter image description here

  • You should be able to put the if/else in the Transition to stage portion. – wjervis Jun 9 '15 at 13:32
  • What would then go in the Top Portion, or can that be left empty? – PnP Jun 10 '15 at 19:09
  • If it can't be left empty, simply log a comment to history – wjervis Jun 10 '15 at 19:15
6

This is by design.

In Update Workflow just check if Modified Date is equal to Created Date. That means it is an update after new file upload.

  • How exactly can I go about achieving that, I am very new to SharePoint! – PnP May 31 '15 at 22:27
  • In your update workflow as a first statement use if currentitem:created is equal to currentitem:modified then stop workflow – Amal Hashim May 31 '15 at 22:28
  • Would that be as a step or stage? – PnP May 31 '15 at 22:39
  • I can't seem to get this working, my statement looks such like: If Current Item:Created equals Current Item:Modified (do nothing) else (Email PersonA). The Transition to stage contains "Go to End of Workflow" – PnP Jun 1 '15 at 10:26
  • 1
    @PnP Modified will not always match Created if they have to fill out metadata after the document upload. – wjervis Jun 4 '15 at 11:57
2
+25

This SE answer explains why this occurs (it's for event receivers, but applies to workflows as well):

When you add a document to your document library the event ItemAdded was called. If you work with the standard upload, after that the document has been added, a popup window will be open to insert the metadata of your document, this fires the ItemUpdated event.

There's no way to prevent both from running, but you can work around it. What you can do is add a field to the library. Your item created workflow will set this field, and your item updated workflow will have to check for it. If it's set, then the item created workflow has already, and the item updated workflow can run. If not, then the item created workflow has not run, and the item updated workflow should not run.

0

Or , if it is designer workflow you can just uncheck relevant checkBox.enter image description here

  • This does not come close to achieving what is required. – PnP Jun 1 '15 at 8:09
0

I think this might do what you need, it's adapted from something I put together on a list where I had a hidden Title field that I generated based on several fields, and another workflow that was ran at the same time would always create tasks with a value under related item of "(no title)", so I made it wait for the title before starting. Expanding on that concept, I came up with this:


Create two "single line of text" fields with a default of blank. Set them to Hidden so the user doesn't put anything in them. Name them "isExistingFile" and "newFileProcess".

Workflow #1 - when new document is added:

[Whatever steps you want the workflow to do]
then
Wait for Current Item:newFileProcess to not be empty
then
Set Current Item:isExistingFile to "Indeed"

Workflow #2 - when document is modified:

If Current Item:isExistingFile is not empty
[Whatever steps you want the workflow to do]
Else
Set Current Item:newFileProcess to "Splendid!"

When a new file is uploaded and triggers both workflows, #2 will see that isExistingFile is empty and know that this is a new file, so it shouldn't follow the edited file steps; instead, it will just set newFileProcess so that #1 can finish. #1 will do what it's supposed to do on a new file, then it will wait however long it has to for #2 to finish before it sets the isExistingFile value, guaranteeing that #2 won't see that value the first time it runs for a given file.

Later, when a file is actually modified, #2 will find a value in isExistingFile and will carry out the normal steps for a previously-added, newly-modified file.

0

You can avoid this behaviour (the two events that fire on upload) by setting the Require documents to be checked out before they can be edited to Yes in the Versioning settings of your library. This way the edit metadata form won't trigger the ItemUpdated event because the file hasn't been checked in after initial upload.

Just be sure to update your workflow to checkout/checkin the document to update metadata otherwise your workflow will fail.

Only drawback: you lose co-authoring since checkout/checkin implies you want sole ownership of the document during editing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.