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

Question

Question

OpenFolderListing not returning all entries

SDK
asked on June 15, 2018 Show version history

I might be using OpenFolderListing wrong, but every time I run the below code, I only end up with about 790 entries. There should be thousands.

	var folderList = new List<int>();
        var els = new EntryListingSettings();
	using (var caseFolders = YearFolder.OpenFolderListing(els))
	{
		foreach (var caseFolder in caseFolders)
		{			
			var caseFolderId = (int)caseFolder[SystemColumn.Id];
						
			folderList.Add(caseFolderId);
		}
	}

It's not obvious to me how to either get all of the entries, or page through them in a way that makes it happy.

0 0

Replies

replied on June 15, 2018

Not sure if it would make a difference but did you try setting the EntryFilter property on the EntryListingSetting object?

    els.EntryFilter = EntryTypeFilter.AllTypes;

 

0 0
replied on June 18, 2018

I just tried that, and it has no effect.

0 0
replied on June 15, 2018

Looking back at a utility I wrote a while back it looks like the OpenFolderListing returns a collection of EntryListingRow objects.  You will need to iterate through that collection with something like;

{
    foreach (EntryListingRow row in yearFolder.OpenFolderListing(els))
        int entryID = row.Item(1);
}

 

0 0
replied on June 18, 2018

The code looks correct. Is this wrapped in a try/catch? there could be an exception thrown midway through the listing.

0 0
replied on June 18, 2018

I simplified the example for brevity, but yes, there is error handling.

0 0
replied on June 18, 2018

And you're sure that the user this code runs as has rights to see all of the entries?

0 0
replied on June 18, 2018

Yes. I'm currently running it as a user who has admin rights in the repository.

I'm trying to reorganize a particular folder structure, so It's walking through all the subfolders in one folder and moving them to a different structure. It successfully moves the folders, but it dies after 789-791 entries. However, if I re-run the process, it will pick up another 789-791 entries, and move those just fine.

Currently I have it running in a while(true) loop, and it seems to happily pick up another chunk of documents each run-through.

0 0
replied on June 18, 2018

Try creating a List<int>, enumerate the folder contents to populate the list, then outside of the using block perform your move operations. The listing might be getting confused when entries in the listing are moved before the enumeration completes.

0 0
replied on June 18, 2018

That's what I'm doing in my example?

Sorry, moving the entries is my end result, but I do collect entry ids and then act on them in another step. The other step is not in question, I'm only getting a limited number of results when I enumerate through the results of OpenFolderListing.

0 0
replied on June 18, 2018

What does it report if you log the RowCount and the length of the resulting list, like this:

var folderList = new List<int>();
       var els = new EntryListingSettings();
using (var caseFolders = YearFolder.OpenFolderListing(els))
{
        Console.WriteLine(String.Format("{0} rows in listing", caseFolders.RowCount));
	foreach (var caseFolder in caseFolders)
	{			
		var caseFolderId = (int)caseFolder[SystemColumn.Id];
					
		folderList.Add(caseFolderId);
	}
        Console.WriteLine(String.Format("{0} rows returned", folderList.Count));
}

 

0 0
replied on June 18, 2018

It returns the number of entries that I would expect. In this case, it's 14491.

0 0
replied on June 18, 2018 Show version history

Maybe the enumeration is encountering an error and silently truncating. Try enumerating the listing like this:

var folderList = new List<int>();
var els = new EntryListingSettings();
using (var caseFolders  = YearFolder.OpenFolderListing(els))
{
    for (int rowIndex = 0; rowIndex < caseFolders.RowCount; rowIndex++)
    {
        EntryListingRow caseFolder = caseFolders.GetRowData(rowIndex + 1);
        var caseFolderId = (int)caseFolder[SystemColumn.Id];
        folderList.Add(caseFolderId);
    }
}

 

0 0
replied on June 18, 2018

Yep. It turns out that I was getting a 9051 error, which lead me down another path which took me to the realization that I had a second instance of OpenFolderListing nested down towards the bottom. Apparently that's a no-no so I refactored things and all is well.

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

Sign in to reply to this post.