Setting a Retention Label in SharePoint from Microsoft Flow

Reading Time: 2 minutes

As time goes on, more capabilities are being introduced to automatically set a retention label on a document rather than having to rely on the end-user to manually set it. As of this date, options include defaulting a retention label at a document library level, folder level, or auto-applying based on either a queryable managed property or a content type.

There still may be times when you need to set a retention label based on a more complex set of conditions not falling into any of the above categories. On the Content Services Roadmap shared at Ignite 2018, there was mention of an action in Microsoft Flow to set a Retention label at a Later time. (red star)

Roadmap - Content Services

Until then, here is how you can set a retention label using a Send an HTTP Request to SharePoint action in Microsoft Flow: (this example is for a non-record label)
Flow Action

Eventually, this capability will be available as an action in Microsoft Flow. Until that time, this is how you can do it. Note: I haven’t tested all of the above property settings for record and event-based labels.

Thanks for reading!

-JCK


Image by LUM3N from Pixabay

21 comments

  1. Joanne,
    Thanks for this wonderful tip. You mentioned in the post that currently options exist to apply default labels to libraries and folders. I am able to find the option to apply the label defaults to libraries but cannot find any option to apply labels automatically to folders inside a library. Is there a specific setting or trick I need to utilize to apply a default label to a folder?

    1. If you set the retention label on the folder thru the UI… detail pane… The documents within will get the label. There are some exceptions but that’s the main behavior.

  2. I am wanting to replicate your demo but am running into issues with the ID that I should use. Do you have a complete walk through you can share?

    1. Hi Douglas,
      You need to first get the document you want to apply the retention label on, and use that document’s Id when setting the retention label.
      -Joanne

  3. This is perfect, I have been struggling to find a solution to set labels based on metadata for my client that didn’t involve an E5 license or 3rd party solution and this works perfectly…

    when I asked Microsoft about RESTful or CSOM options they told me none existed, I guess they prefer people to purchase E5 licenses.

  4. Hello Joanne,

    Your article gave me a start towards my solution, but I am stuck here:

    In my case, I have retention labels that I am going going to apply to the documents. So, the document expiry would happen based on the expiry date that Retention label carries.

    [example:- Doc A has 1 year retention label. so, 10 days prior to that the author/owner of that document should receive the notification]

    How can I achieve this notification/trigger depending on the Retention label expiry.

    Thanks in advance

    1. Hi Gurujyot,
      I don’t have enough information to completely answer your question. Do you have a disposition review configured on your retention label definition? If so, the notification doesn’t happen 10 days prior to the disposition date, It is controlled by a back-end process that runs once per week so the notifications will be sent out up to 7 days after expiry. You don’t control that part. If you just have a retention label and you’re controlling the notification yourself, you’d have to know the expiry date, I’ve never seen how to get that but presumably you could get it thru an API call,
      -JCK

  5. Thanks @Joanne

    Do you have some helpful article that can help me out? Articles that I can use to call API through SPO.(I haven’t done this in past)

  6. Apologies to resurrect an old thread, but does anything know if it’s possible to apply Retention Labels to Items within a SharePoint List using a Flow? Thank you

  7. Hey Joanne, is there an equivalent option in the REST API for updating a sensitivity label?

    Thank you in advance!

  8. Hi Joanne – I am getting the label set successfully and I can see it appearing in the view of the items under retention label column but its not actually preventing me from deleting the item nor can I see that is it keeping them in preservation items on the site or anything similar. Am I missing something?

    1. Hi Lorna, it depends on the configuration of the retention label and what the tenant level setting is for allowing end users to delete labeled docs.
      Make sure your retention label has a retention component on it. I.e. it can’t be a “don’t retain or delete” label or a “delete only” label… neither of those will prevent you from deleting a doc with the label applied.
      -Joanne

      1. I am the builder of the retention architecture as well (which I have done many time before) so I am at a loss as to why this occurred – its a 7year retention label with a leave in place action after period ends.

      2. Hi Lorna, hard to t-shoot over this channel. Something to check that may help you t-shoot:
        If you manually apply the label does it let you delete it? If not, then look at the flags in your API call, they may affect the behaviour. Is this a record label?
        – Joanne

      3. Yes applying label manually definitely works properly so I think it must be something to do with how Flow applies it. Its not a record label – just a standard retain then do nothing action

  9. Thanks Joanne. For anyone unsure which ID to use, you will need a ‘Get files (properties only)’ step and also a trigger – for instance a manual or scheduled trigger. Once you have a ‘Get files’ step, the Dynamic content panel will then give you ID to use. Be aware that the ‘Get files’ step will add an Apply to Each step in.

    The flow runs successfully – however I’ve found it doesn’t set the Retention Label on all files. I’ve found I’ve had to run the flow a few times to reduce the number of files with the old labels on. I still had several files where the label hadn’t been applied. The workflow hadn’t errored.

    Any ideas why this should happen? Thanks.

Leave a Reply to ColinCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.