web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / undeclare in place rec...
Power Automate
Unanswered

undeclare in place record from Power Automate

(0) ShareShare
ReportReport
Posted on by 4

Hi,

 

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. I am trying to update the record related properties using update file action, but it is not working. Is they any other way to achieve it ?

 

Thanks in Advance

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Dhileep_Varma,


    Just to double check. Are you using retention labels from the Security & Compliance center or are you by any chance still using the classic feature (https://joannecklein.com/2019/01/06/modern-vs-classic-in-place-records-management-in-sharepoint/)?

     

    If you are using Modern you can use the Graph API to retrieve the retention label and check with a filter array action if it is assigned. I tried adding it within the $expand, Graph API didn't like that 😁

     

    Below is an example of that approach for the retrieval part of your question:

    Replace the SiteId and ListId by your ids. Change the retention label in the Filter Array to whatever label name you were using in your setup.

     

    recordmanagement_label.png

     

     

     

     

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Dhileep_Varma,

     

    For the second part of your question, about undeclaring items. You could remove the label (as a site collection admin). You could use the SetComplianceTag method and set the tag to empty/none. This should undeclare it.

     

    Can you try the approach below.

    As you can see the apply to each action uses the body of the filter array action.

     

     

    _api/web/lists(guid'@{variables('ListId')}')/items(@{items('Apply_to_each')['ID']})/SetComplianceTag()

     

     

    removecompliancetag.png

  • Dhileep_Varma Profile Picture
    4 on at

    Hi,

    Thanks for your response. We are not using the rentention labels feature. These are all the documents manually declared as records by users for last 3 years. 
    As per the new ORG policy change we want to undeclare all the existing records through out the tenant.

     

    I tried with the graph api option but it fails when i use Complaice Tag propery. Any idea ?.

     

    Thanks 

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Dhileep_Varma,


    ComplianceTag is from Modern record management. It looks like you are using classic in place record management. In that case you can look for the OData__vti_ItemDeclaredRecord field. When an item is declared as record you could filter on it that field not being empty.

     

    Below is an example for the retrieval part.

     

    declareditemsasrecords.png

     

    For the undeclaring part I am afraid it is a bit more limited. I have not seen any REST API endpoints for the UndeclareItemAsRecord method.

     

    The internet is full of examples of using CSOM with PowerShell though. That is probably the easiest approach for this feature.

  • Dhileep_Varma Profile Picture
    4 on at

    Sorry for the delayed response. I tried the CSOM approach & it worked well in my dev & test tenants. But not working in PROD tenant. Any suggestions on this ?

     

    I tried another option to use pnp instead of csom, it works fine to connect to the site & iterate the library documents. But i dont see any option to undeclare the record documents using pnp powershell and to get the client run time context using pnp.

     

    Thanks in advance for your help on this issue.

     

    $listname = 'ListName'
    $Username = 'Email address removed'
    $password = Read-Host -Prompt "Enter password" -AsSecureString

    $url = 'https://abcsharepoint.com/sites/test'
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
    [Microsoft.SharePOint.Client.ClientRuntimeContext] $runTimectx = [Microsoft.SharePOint.Client.ClientRuntimeContext] $ctx.Web.Context;
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
    $web = $ctx.Web;
    $ctx.Load($web);
    $ctx.Load($web.Webs);
    $ctx.ExecuteQuery();

    $listUpdate = $web.Lists.GetByTitle($listname)
    $ctx.Load($listUpdate)
    $ctx.ExecuteQuery()

    #CAML Query to get all items inclusing sub-folders
    $spQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
    $spQuery.ViewXml = "<View Scope='RecursiveAll' />";
    $item = $listUpdate.GetItems($spQuery)
    $ctx.Load($item)
    $ctx.ExecuteQuery()

    for($j=0; $j -lt $item.Count; $j++)
    {
    if($item[$j].FieldValues["_vti_ItemHoldRecordStatus"] -eq 273)
    {
    [Microsoft.SharePoint.Client.RecordsRepository.Records]::UndeclareItemAsRecord($runTimectx,$item[$j])
    }
    }

     

    Error :

    Exception calling "ExecuteQuery" with "0" argument(s): "The sign-in name or password does not match one in the Microsoft account system."

    At line:12 char:9

    +         $ctx.ExecuteQuery()

  • jherschel7 Profile Picture
    27 on at

    Great information @Dhileep_Varma and @Expiscornovus , this is very close to something I am trying to achieve.  I am looking for a way to SET the ComplianceTag default on a document library for every SharePoint site we have, but have not found this solution.  Have you done this?  I was able to find a way to Get and Set via PnP-GetLabel, but would love to use Power Automate.  Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard