Getting documents from a specific library
Hello,
I had difficulties getting documets from a library i called "JobApplications", so I debugged step by step the following code :
string title;
int i;
int iCount;
App.WorkWith().DocumentLibraries().ForEach(lib =>
title = lib.Title;
i = lib.Items.Count;
);
App.WorkWith()
.Documents()
.Where(item => item.Parent.Title == "JobApplications" && item.Status == ContentLifecycleStatus.Live)
.OrderByDescending(item => item.DateCreated)
.Count(out iCount);
App.WorkWith().DocumentLibraries().ForEach(lib =>
...").App.WorkWith().Documents().Where(...)), I try to look for documents which belong to the library named "JobApplications", and count them.
I find 0 documents, while the first part counted 4...
Is there something i did wrong? Am I counting the documents i thought?
Thank you,
F
Hello F,
You can try getting the library by its title, and then you can directly access the stored documents in that library. Please note you'll also need to filter for the Draft states of the documents. I've provided a small code sample that's getting all the documents with Live state from my Default Library, please take a look at it, hope it helps you achieve the desired functionality.
var library = App.WorkWith().DocumentLibraries().Where(lib => lib.Title ==
"Default Library"
).Get().First();
var documents = library.Documents.Where(d => d.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).ToList();