Can anyone help with creating a search syntax to find the newest document in a folder? I'm sure it very easy. I am just drawing a blank right now.
Question
Question
Search for the newest document in a folder
Replies
The easiest way to figure out Search Syntax is to enable it in the Client and do the search you want, then copy the search syntax it creates.
So for your situation, you will want a Date search and Search Syntax enabled, then in the date search, select the created/last modified/created or last modified, then select Today as the date (which in workflow you can pass as a token).
{LF:Modified="5/30/2018"}|{LF:Created="5/30/2018"}
But I don't know if they have any in the folder that was created on 5/30. So my search would return as zero. One folder might have 2/30/14 as the latest document entered. I just want the latest date. The Date Search you must know when it was created or modified.
I think the easiest is to combine "Within Folder" and "Date" criteria. You should give a minimum time frame to narrow down your results otherwise you're just retrieving all documents in a folder. Select for example "created within last 15 days" and choose the specific folder where you're performing the search ({LF:Created>="16/05/2018"}) & {LF:LOOKIN="FOLDER NAME"}. Then sort the results by creation date to see the newest document
But I have over 4,000 folders. I'm not positive each folder contains documents from the last 15 days. Some if could be years. These are invoices from vendors. So we may have used a vendor in 2014 and never used them again. We are trying to see the invoice each vendor sent us in a report.
The only way I think we can do this is by creating shortcuts to the documents in a separate folder via workflow. And using columns to pull the report.
If you have any SQL access and a little bit of background, you can do something like this (since it is a LOT simpler): https://answers.laserfiche.com/questions/142410/Workflow-Last-Modified-Date#142433
So maybe you do a search for all folders, then you do for each entry (in this case folder) then do a query that looks for the most recent one.
It is a similar concept for the query but it will be in a different table and in the repository DB instead of workflow.
My suggestion is that if you have a unique template for all of them is to create a SQL View and then query from that. Let me know if you need help with it!
No I don't have any SQL access. I was hoping it wouldn't involve SQL. Oh well, thanks for your help. Back to the drawing board. Seems like this will be a manual process.
You don't have to have access to it to query it through workflow though :) Is your SQL server on prem?