Forum Discussion
Changing "retention type" on an existing retention label in MS Purview
- Nov 28, 2022
Hi K-dub,
Thanks for the question! Here is a link to the documentation about modifying existing labels: Create retention labels for exceptions - Microsoft Purview (compliance) | Microsoft Learn
"Most settings can't be changed after the label is created and saved, which include:
- The retention label name and the retention settings except the retention period. However, you can't change the retention period when the retention period is based on when items were labeled."
So, you can change the retention period for a label, but nothing else. If you'd like to change the other settings, the best process is to create a new label and use PowerShell to replace it 1:1 with the old label.
Please let us know if you have other questions.
Thanks!
Erica
Hey EricaToelle! I hope everything's well with you! This is relevant to my interests. I'm going to have to show a client how to do do this soon (create the new labels and use PowerShell to replace them 1:1). Do you have any advice on what thread to start pulling to figure out how to do that?
Nick Brattoli Consider using the Set-PnPListItem cmdlet with the '-ClearLabel' and/or the '-Label' params to clear or assign a new retention label on an existing list item.
Refer this example: https://pnp.github.io/powershell/cmdlets/Set-PnPListItem.html#example-4
Hope that helps! Cheers!
- EricaToelleNov 14, 2023
Microsoft
This method is not recommended or supported by the Records Management product team. - ellan1537Nov 14, 2023Iron Contributor
Kuljeet Singh EricaToelle - I've the same requirement where I've to update/replace the old retention label with the new one that has been already applied to the content.
For this purpose I'm using PowerShell script and below is the error. Can you please assist me here?
ERROR: "Set-PnPListItem : Invalid data has been used to update the list item. The field you are trying to update may be read only."
PnP:
# Get all the items that have the old retention label
$items = Get-PnPListItem -List $libraryName -Query "<View><Query><Where><Eq><FieldRef Name='_ComplianceTag' /><Value Type='Choice'>$oldRetentionLabel</Value></Eq></Where></Query></View>"
foreach ($item in $items) {
# Update the retention label to the new one
Set-PnPListItem -List $libraryName -Identity $item.Id -Values @{"_ComplianceTag" = $newRetentionLabel}
}
- EricaToelleNov 14, 2023
Microsoft
ellan1537 The records management product team does not recommend using PnP to work with retention labels. Please use the supported methods in the official documentation: https://aka.ms/DLM/CSOM.
We also introduced Methods to the driveitem object in SharePoint to apply and manage retention labels applied to items in SharePoint:
- driveItem - Microsoft Graph beta | Microsoft Learn (method section anchor)
- More info on APIs introduced:
- Get retention label applied to items - driveItem: getRetentionLabel - Microsoft Graph beta | Microsoft Learn
- Set (apply) retention labels on items - driveItem: setRetentionLabel - Microsoft Graph beta | Microsoft Learn
- Remove retention labels from items - driveItem: removeRetentionLabel - Microsoft Graph beta | Microsoft Learn
- Lock and unlock records - driveItem: lockOrUnlockRecord - Microsoft Graph beta | Microsoft Learn