This is one of those posts that’s been in my head for a while. I had some time on the couch last weekend and was prompted by a question in the SharePoint forums so I spent some time looking into the inner workings of a Record in SharePoint 2010. This is part 1 of 2 where I’ll list my findings regarding how SharePoint (internally) declares items as a record. In other words, what really happens when you click “declare as record” in the UI. Part 2 will use this info to create a search page to allow users to search all records.
Most of this was discovered using ILSpy to look into the methods SharePoint uses when an item is declared a record and when it needs to determine if an item is a record. I’ll start with the latter.
Within the Microsoft.Office.RecordsManagement.RecordsRepository namespace within the Microsoft.Office.Policy assembly, there is a method called Records.IsRecord(SPListItem item). Long story short, that method will eventually get you to a common utility method called GetHoldAndRecordStatus which pulls out the value of a HoldRecordStatus field:
|Title||Hold and Record Status|
A few notes here. First, notice it’s a Double. Hmmm, magic numbers? Maybe. Also notice it’s hidden, and it seems to cover both items on hold and flagged as a record judging by the name. If you pull out the value of this column from an item that has been marked as on hold or as a record, here are the values you’ll see:
|Normal record||Empty, or 0|
I’m sure there are other combinations of numbers that will work, judging on how the math is done internally in the other methods. Basically, they add a mask (int) depending on what you’re doing. The mask for records is 16 and the mask for holds is 4096. Someone better at math can open up those classes and let me know how the numbers are actually used.
Another column that’s used in this process is:
This is basically the timestamp for when the item was declared a record. It gets populated when the item is declared, and cleared out when it’s undeclared. Note that it’s not hidden.
Now we know two properties on the list item that are set when an item is declared a record. Now what? How about we use them to search for all records?!?