In SharePoint Online you can declare and undeclare records in place. In this article I am showing you how you can undeclare such a record via the Graph API and Power Automate.
This question from Dhileep_Varma:
I am trying to create a workflow which goes through all the documents in the site collection & check if it is already declared as record. If so i want to undeclare it as record without using Plumsail actions.
Power Users Community thread: undeclare in place record from Power Automate.
In Place Records
It is probably useful to know that there are different ways of declaring and undeclaring records. If you want to know a bit more details about this subject I can highly recommend the Modern vs Classic In Place Records Management in SharePoint article from Joanne Klein as a starting point. She has a lot of great articles about this topic as well, so definitely check out this site.
In this article I am focused on the Modern (In Place) undeclare scenario. Below is a small animation how declaring a record would work via the SharePoint interface. Undeclaring would be similar by just setting the label to none. In this article I want to achieve that via Power Automate
Enumerate items in a list
Lets start by finding all the declared records in a document library.
Normally I would use the Send an HTTP request to list items and its metadata. But in this instance I thought it would be fun to use the Enumerate items in a list method from the Graph API.
In this setup I am using an $expand parameter to also retrieve the _ComplianceTag & IsRecord fields. This gives me the option to check if an item is declared as a in place record.
Note: I tried to also use a $filter parameter in the same URI. I did not manage to get that working with the _ComplianceTag field. Maybe I will have another attempt later to get this working as well.
Before you start: make sure the account you are using for the SharePoint connection is Site Collection Administrator. Thanks Joanne for giving me the heads-up that I forgot this in my blog
1. Add a Manually trigger a flow trigger action.
2. Add a two Initialize variable actions. Make sure both are of type string and they are storing the GUIDs of both the site and the list.
3. Add a Send an HTTP request action (from the Office 365 Groups connector). Use the URI from the code snippet below.
This action is still in preview but not Premium, unlike the HTTP request action.
4. Add a Filter Array action. Use the value field of the body in the From. In the criteria check if the _ComplianceTag field value is equal to your specific label.
In my setup that label is RecordManagementLabel.
5. Add an Apply to Each action. Use the Body field of the Filter Array action.
This action will loop through every item which has the label.
6. Add a Send an HTTP request to SharePoint action within the Apply to Each loop. Select your site in the Site Address. Use a POST method. Use the URI & Body from the screenshot or code snippet below.
This step sets the value of the _ComplianceTag to an empty/none value via the SetComplianceTag method. This will undeclare the record.
That should be it for the setup.
This blog is part of SharePoint Week. Find more here.
About the Author:
My name is Dennis. I am Dutch and I live and work in the UK as an IT consultant. Currently I work a lot with SharePoint online, Microsoft Teams and all the other products of the Office 365 platform. I also like my share of Dynamics 365 and Azure. I try to blog about everything I come across in my daily job. All the content in my blogs are my personal views and experiences.
Dennis. (2022). Undeclare a record (in place). Available at: https://www.expiscornovus.com/2022/03/24/undeclare-a-record-in-place/ [Accessed: 27th April 2022].