I created and tested a workflow, and I recommend working with data that has a specific CustomerID.
Data Retrieval: First, I used the Get Items action to retrieve data with CustomerID 566.
Variable Initialization: Next, I added an "Initialize variable" step and defined this variable as an array.
Date Formatting: In the "Apply to each" step, I extracted the relevant dates using formatDateTime(items('Apply_to_each')?['Date'])
.
Identifying the Last Date: I added a Compose action, naming it "LastDate," to capture the most recent date using the expression formatDateTime(last(sort(variables('SortedDates'))), 'MM/dd/yyyy')
.
Checking Today's Date: I added another Compose action named "CheckDateToday." In this step, I used the expression if(less(formatDateTime(outputs('LastDate'), 'yyyy-MM-dd'), formatDateTime(utcNow(), 'yyyy-MM-dd')), 'true', 'false')
to check if today's date is less than or equal to LastDate.
Adding a Condition: Finally, I included a Condition action that executes the necessary adjustments if the result of "CheckDateToday" is true.
By following these steps, you can create an effective workflow that processes data within a specific date range. I believe this approach can be useful in your own applications as well.
Hello dKayt,
To solve this issue in SharePoint, you can use Power Automate to create a flow that automatically changes the status of all items to "inactive" once the last date is due.
Schedule the Flow: Set the flow to run daily (or at your preferred frequency).
Retrieve Items: Fetch all items from the SharePoint list.
Loop Through Each Item:
Compose Condition:
if( less( formatDateTime(items('Apply_to_each')['Date'], 'yyyy-MM-dd'), formatDateTime(utcNow(), 'yyyy-MM-dd') ), 'true', 'false' )
This checks if the item's date is earlier than the current date.
Condition Check:
Update Item: