Workflow that collects create date of documents and archives

  • 13 April 2016
  • 7 replies
  • 2 views

Badge +1

Dear all,

I would like to create a workflow that runs in a library.  This workflow will look at the date of the creation of the document and then based on if it is 3 days old, it will take that document, move it to another library and then delete it from the first library.

I have so far got to the point where I can select one document and it runs.  But, I am not sure what kind of looping I need.  Not sure if I need to run through the library and collect all documents which meet the criteria, then run.  Or run for each...

This is what I have so far.

workflow.jpg

I am learning about looping, but I get a little tangled up when trying to set variables and building a list.  Any help is appreciated.

Thank you,

Mark


7 replies

Badge +11

Hi Mark,

I would do the following:

  • Use a "Query List" action to query your library and get the ID of all the items and save it in a collection variable
  • Use a "for each" action to loop through all of your IDs and put the current ID in a variable
  • Use another "Query List" inside your loop to query only the one item with the ID you currently have
    • Get the "Created" info of that item and save it in a variable
  • Use a condition to see if the date is older than 3 days
  • If so, do your magic otherwise just do nothing (If you don't need the "no" path you can use a "Run If" container)

However, please have a look at SharePoints retention policies and see if they aren't what you looking for.

Regards

Philipp

Badge +16

Philipp Lucas​ am I correct in thinking you are describing a site workflow above? 

An alternative option is to have a workflow that runs in the library on every item created, waits for 3 days, then does the copy and deletion?

Badge +11

Yes, you are correct. I was talking about a site workflow. I would chose a site workflow over a list workflow here because it can reduce the number of running workflow instances significantly. The more workflow instances we have running, the more errors can occur. Besides it gets more difficult to evaluate/analyze the workflow. Always try to keep it simple wink.png

Regards

Philipp

Badge +1

Hi Philipp,

Thank you very much for your answer.  I will try your advice today... :-).

Mark

Badge +1

Hi Philipp,

In your comments, you say I should use a For Each loop to put the current id into another variable.  What type should I make this variable (i.e. collection, list item ID, etc.)?

Badge +11

Hi Mark,

variable should be of type list item ID or single line of text (my favorite). Not sure if number and integer would work. A collection variable won't work, because you cannot put one single value of a collection into another collection.

Regards

Philipp

Badge +1

IT WORKS!!!! :-).  Thanks all for your help

Mark

Reply