Hi
It's Vault 2023 SDK.
I'm trying to develop API to get properties of all files within one folder.
Root folder is "Drawings", but it has many sub folders inside.
Folder folder = mVault.DocumentService.GetFolderByPath("$/Drawings");
File[] filearray = mVault.DocumentService.GetLatestFilesByFolderId(folder.Id, true);
Need recommendation if there is any easier method to get all files name and id from all folders inside, or I have to keep looping looking for files for each folder
Also once list of files is acquired, there is need for user-defined metadata, which I don't know what method and how to retrieve it yet.
Please help, thanks.
Solved! Go to Solution.
Solved by Nick_Hall. Go to Solution.
Hi
You could try using FindFilesBySearchConditions, setting the SrchCond to Folder Path Contains "$/Drawings"
It's probably faster than looping through each folder, but it will depend on your Vault
To retrieve the metadata, you will need to use PropertyService.GetPropertiesByEntityIds if you want all the properties or PropertyService.GetProperties, if you know which properties you want.
To find the Property Definitions, use PropertyService.GetPropertyDefinitionsByEntityClassId.
Hope that helps
Nick
Hi Nick,
Thank you.
Is there anyway to make this method FindFilesBySearchConditions return more than 500?
Because it seems to be at max 500 results
Hi
FindFilesBySearchConditions returns files in batches, the batch size is set in Vault
You need to loop through to get the full set
You will find an example in the VaultBrowserSample in the SDK. Look in FinderForm.cs
This is the section you're looking for
List<File> fileList = new List<File>();
while (status == null || fileList.Count < status.TotalHits)
{
File[] files = m_connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(
conditions, null, null, true, true,
ref bookmark, out status);
if (files != null)
fileList.AddRange(files);
}
That should help you
Nick
Hi Nick,
Thank you, it works.
One last question, is it possible to get user defined properties from FindFilesBySearchConditions
Or I have to loop to fetch properties with PropertyService.GetPropertiesByEntityIds for every file.
Because total files are more than 100K, so I want it to process faster.
Hi
You can get the properties from multiple entities using GetPropertiesByEntityIds
Just pass in an array of all the entity IDs (from fileList in the previous example)
That will give you everything in a single call, but you may want to retrieve them as part of the while loop if the number of files found is very large - sometimes Vault doesn't perform well if you ask it to do too much in a single call.
Nick
Hi Nick,
Thank you, I've finished the implementation.
Just my curiosity, while using FindFilesBySearchConditions, sometimes I found that one file, but it responses to me as 2 records, only different by state of lifecycle, Published and Work In Progress.
If I want to have only "Published" state with FindFilesBySearchConditions, is it possible? or do I need to filter after getting the data.
Hi
If you are getting more than one version of a file, you must be setting latestOnly to false
To filter so that you just get “Published” states, you need to add another search condition of “State (Historical) = Published”
Nick
Can't find what you're looking for? Ask the community or share your knowledge.