You are viewing limited content. For full access, please sign in.

Question

Question

Find Oldest Document in a Folder

asked on October 14, 2014

I need workflow to search within a particular folder (that contains multiple documents) and return the document with the oldest Creation Date. I'm using the Search Repository activity to do a search within the folder for all documents, and I'm retreiving their creation dates using the search's Additional Properties, but I'm not sure how to compare the dates and return the document with the oldest one.

Any guidance would be great!

Thanks - Jim

1 0

Answer

SELECTED ANSWER
replied on October 14, 2014

Hi Jim,

I've attached an image of a workflow to do this. What you need to do is create 2 tokens, one to keep track of the oldest date you've seen and one to keep track of that document ID. Then search the repository and go into a For Each Entry loop. In that loop compare the current date and see if it is less than (older) than the Oldest date you've seen. If it is, update the Oldest date and the Current document. When you're out of the loop you'll have document with the oldest creation date.

Find Oldest Creation Date.png
5 0
replied on November 18, 2014

Thank you. I have used the assign token values before, but only to create tokens. I hadn't paid much attention to the modify function, but that is perfect. This is exactly what I needed!

 

(I was looking around to find a Min or Max on a multi-value token or something, silly me!)

0 0
replied on November 18, 2014

There are Min and Max functions you can apply to multi-value tokens too! Go to the token dialog, select the multi-value token you want then click "Apply function." Scroll through and you can apply Max or Min! 

The applied function will end up looking like this %(Multiple Token#@Max@#)

Max.png
Max.png (53.86 KB)
1 0
replied on November 20, 2014

I actually did try that before I found this modify token suggestion. I am missing a bit of the logic that tracks all of those values and then calculates the Max. I tried pulling the creation date into a multi-value token and applying the Max, but couldn't make it work. This was easier for me to figure out how to do. And, I just used it in 2 workflows and they work! Thank you.

0 0

Replies

replied on October 15, 2014

This worked perfectly, Kevin - thanks so much for the assistance!

0 0
replied on October 15, 2014 Show version history

Wouldn't this workflow only need to loop through each entry and if it's entry id is less than the current one in a token then it overwrites the value of the token with the new lowest number? Or is the creation date not the date of creation in the system?

0 0
replied on October 15, 2014 Show version history

Documents imported through briefcases keep their creation date from the original repository, but they get new IDs. So the oldest ID is not guaranteed to be the oldest document in terms of creation date.

1 0
replied on April 8, 2019 Show version history

Are there any screen shots of how to set up the tokens?

0 0
replied on April 9, 2019 Show version history

Newer versions of Workflow don't need this setup anymore. The Search Repository activity allows for sorting results by any properties, including the creation date, in ascending or descending order. If you set the activity sort by creation date in ascending order and to return only one result, that will be the oldest document in the folder.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.