Microsoft's latest release of the New SharePoint CSOM version released for SharePoint Online includes many requested new capabilities that developers have been begging for. Key updates include the ability to bulk edit User Profiles, access the Recycle Bin, reading content from older documents versions - and much more.
But for me at least, the most exciting inclusion was the Records class. FINALLY!!!
The Records Class
This includes three simple methods which should be self-explanatory.
- IsRecord: Checks whether the specified item is a record.
- DeclareItemAsRecord: Declares the specified item as a record.
- UndeclareItemAsRecord Undeclares the specified item.
The View
In order to get an idea of how many records I was dealing with, I first created a view on the target library which included the Declared Record and Item is a Record system fields, and showed totals.
I also enabled Metadata navigation on the library and specified the Declared Record field as a key filter. This is pretty much mandatory for large libraries in order to overcome potential List View Threshold errors. It also has the added benefit of removing folders once the filter is applied.
Interestingly, Item is a Record always displayed No, despite the padlocked icon and presence of a Declared Record date. Seems this is tied to the IsRecord method problem explained later.
The Console App
Firing up VS, I created a new console app project and added it to my ever-growing solution of "Handy apps that every SP admin needs but never knew existed". ;)
After defining a suitable CAML query with enough indexed columns (please tell me there's a better way to query HUGE lists!), I then decided to perform a test against each item in the set to satisfy myself that it actually was a record. And this is where I hit my first snag. The IsRecord
method returned false
for every item.
Hmmm....I'm wondering if there's any correlation between the returned Boolean from this method and the value displayed in the Item is a Record field in my view. In any case, I had my CAML query and view to confirm the items were indeed records. So I just removed the check and went ahead with undeclaring them.
I'm very happy to say that the exercise was a success and saved many days of manual work.