Undeclare / Declare all / some records in a list

Requirement

Undeclare all records in a SharePoint list. Declare all records in a SharePoint list. Declare only specific records in a SharePoint list.

Solution

Use the following PowerShell script.

$SPAssignment = Start-SPAssignment
$web = Get-SPWeb <a href="http://your-site">http://your-site</a> -AssignmentCollection $spAssignment
$list = $web.lists["your-list"].items
foreach ($item in $list)
{
	$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
	if ($IsRecord -eq $true){
		Write-Host "Undeclared $($item.Title)"
		[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($Item)
	}
}
Stop-SPAssignment $SPAssignment

To declare all items as a record, change the relevant code above to the following:

	if ($IsRecord -ne $true){
		Write-Host "Declared $($item.Title)"
		[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::DeclareItemAsRecord

To declare specific items as a record, based on a condition

	$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
	if ($IsRecord -ne $true){
		if ($item["Status"] -eq "Completed")
		{ 
			Write-Host "Declared $($item.Title)"
			[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::DeclareItemAsRecord($Item)
		}
	}

This will declare as record only items that have ‘Status’ equal to Completed.

Tags: , ,

4 Responses to “Undeclare / Declare all / some records in a list”

  1. Charles February 13, 2014 at 1:24 am #

    godlike

  2. hkwan April 22, 2015 at 6:53 am #

    Amazing!

  3. Raghad May 14, 2015 at 6:42 am #

    Based on my knowledge we can undeclare the list item by the following steps:
    1- Go to the view that you need to declare a specific item from it then Go to the (list) then (list settings) then Go to (Record Declaration Setting) and check on (Always allow the manual declaration of record).
    2- Go to the (All item view) and search on the item that you need to undeclared it, then Go to the downward arrow on the right of the item (from the 1st column)and choose (Compliance details) then select undeclared item.

  4. ian hayse April 16, 2016 at 2:34 am #

    You can also bulk declare records.

    Records.BulkDeclareItemsAsRecords method:
    https://msdn.microsoft.com/en-us/library/microsoft.office.recordsmanagement.recordsrepository.records.bulkdeclareitemsasrecords.aspx

Leave a Reply

%d bloggers like this: