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 / Issue building a flow ...
Power Automate
Unanswered

Issue building a flow based on a Retention label column

(0) ShareShare
ReportReport
Posted on by 65
Hi All,
 
I need help with building a Power Automate flow based on values set in couple of columns.  
 
I have a SharePoint Document Library called "Working Documents" as below. It has 2 key columns based on which I want to build the flow.   They are "Retention label" and "Retention elapse date". 



My idea of the flow is that it should trigger when a value is selected for "Retention label" column for any folder in this library. Then need a condition (or maybe a switch statement) based on retention label column.  Lets say if value  for the "REtention label"  is test-3 years, then update "retention elapse date" column with 3 years from now.  Similarly if value in retention label is test-5 years, then set the elapse date value to 5 years from the label applied date
 
I have started building the flow but having trouble even getting the flow to trigger. The flow should fire only when I populate the "Retention label" column for a folder with a value, and then the other actions follow.    Here is the flow trigger & the trigger condition I set



Trigger condition is below
 
Note :  I found that the actual name of the "Retention label" column seems to be "Compliance tag" as per the url (as per screenshot below). I just sorted this column by desdending, so the URL was looking like the below. Hence I assume that this is the actual name of the column which I should be using in the flow trigger


 
But this flow doesn't even trigger (let alone building the rest of the flow conditions for retention label values).
 
Can you please help me build this flow with following requirements : 

-Flow to trigger when any folder has the "retention label" Column populated with a retention label value
-Then depending on the value selected in this retention label column (I assume its called ComplianceTag), the flow should have different branches that set a value in the "Retention elapse date" Column (Ie, if label is 3 years, set the elapse date value to 3 years from now etc)
 
Please help me with this requirement
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    As far as I am aware that specific trigger action doesn't return the _ComplianceTag property in the body. So, you would need an additional action in your setup to check this.
     
    But you might be able to solve this with a calculated column or some column formatting as well. Just use the value of the Retention Label Applied column and calculate the new elapse date based on the retention label selected.
     
    I can share an example if you are interested in that approach?
     
  • Pacel1 Profile Picture
    79 on at
    Your screen with link from sharepoint says the name of the column is   _ComplianceTag Not ComplianceTag as You put in condition, 

    To be sure of column name You can:

    1. Open list settings
    2. Click and open in new window column Compliance Tag
    2. Check the URL at the and You should see the presentation of column name for Your Rule

  • SPUser1980 Profile Picture
    65 on at
    Hi
     
    Thanks for the answers, I am unable to reply to your replies. Apologies for that, not sure why I can't reply
     
    Expiscornovus please share your approach in detail, so that I can try.
     
    I tried all trigger conditions below (for flow to fire when this field "_ComplianceTag" is empty). But none of them is working
     
    @not(empty(triggerBody()?['_ComplianceTag']))
     
    But when I try the above trigger condition with another choice column name (instead of compliancetag), flow triggers. 
     
    So I need help with
     
    1. Get to trigger flow with the above trigger condition (only when this coluimn) is populated with a value
    2. Then the other date column (elapsed date) Should be populated with a future date based on the value selected for the retneiton date (ie, compliancetag)
     
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    Below is an example of column formatting

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=if([$_ComplianceTag] == 'Trigger Flow after 1 Month', addDays(Date(toLocaleString([$_ComplianceTagWrittenTime])), 30), '')"
    }
    ​​​​​​​
  • SPUser1980 Profile Picture
    65 on at
     
    Thanks for your inputs. I tried your JSON as below  (Note I put 1095 days as it equates to 3 years).
     
    TRIAL 1 : (YOUR SUGGESTION) : 
    --------------------------------------------
    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if([$_ComplianceTag] == 'test-3yrs', addDays(Date(toLocaleString([$_ComplianceTagWrittenTime])), 1095), '')"
    }
     
    But when I try with your logic, it says "invalid date" in the Elapsed date column

    TRIAL 2 (ANOTHER SUGGESTION I TRIED) : 
    ---------------------------------------------------------


    I tried another JSON format below.
     
    The below JSON worked, and the "Retention Elapse date" is showing 3 years from now. But the issue with below formula, is that it calculates 3 years from "Now", irrespective of when "Retention label" column was populated.   Can you help me format below logic to work based on when the retention label was populated and not from "now"

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=if([$_ComplianceTag] == 'test-3yrs', @now + 365*3*24*60*60*1000, '')"
    }
     

     
     
    Also I need to add another conditon  -  if the label is "Indefinite", then populate 10 years from now..  I tried to modify the trial 2 code with this one below, but it gives an error. Please advice whats wrong with the below syntax as well.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "white-space": "nowrap"
      },
      "children": [
        {
          "elmType": "span",
          "txtContent": "=if($_ComplianceTag == 'test-3yrs', @now + 365*3*24*60*60*1000, if($_ComplianceTag == 'Indefinite', @now + 365*10*24*60*60*1000, ''))",
          "style": {
            "font-weight": "bold",
            "color": "#000000"
          }
        }
      ]
    }
    }
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    Just to double check, did you add Retention Label Applied to the view? Make sure you add the Retention Label Applied also to your view, that is required for the expression in the column formatting to work.
     
  • SPUser1980 Profile Picture
    65 on at
     
    Sorry I missed creating the calculated column  "Retention label applied". My apologies.
     
    Can you show me screenshot of what is the type of this column? How did you get the date to populate in this "Retention label applied" Column. Can you show this column settings so that I can create this column, and then add it to the view?
  • SPUser1980 Profile Picture
    65 on at
     
     
    Sorry didn't quite understand how you built the logic to populate the "Retention label applied" Column. 

    Can you show me screenshot of what is the type of this column? How did you get the date to populate in this "Retention label applied" Column. Can you show this column settings so that I can create this column, and then add it to the view?
  • SPUser1980 Profile Picture
    65 on at
     
    Sorry didn't quite understand how you built the logic to populate the "Retention label applied" Column. 
     
    Can you show me screenshot of what is the type of this column? How did you get the date to populate in this "Retention label applied" Column. Can you show this column settings so that I can create this column, and then add it to the view?
  • SPUser1980 Profile Picture
    65 on at
     
    It seems to have worked now. Thanks

    I just used the system default "Retention label applied" column to this view (Just realized this is a system default column and there's no json or formulae needed in this column).

    Now it is populating "Retention Elapse Date" correctly, with your logic.



    Just one more question though. If I need to add another condition for another retention label, how do I edit your syntax? (Lets say if "_ComplianceTag" is 5 years & indefinite). Can you help me with that as well?

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard