Skip to main content

Notifications

Power Automate - General Discussion
Suggested answer

How to write my Update item

(0) ShareShare
ReportReport
Posted on by 449
 
Hi All,
 
I want to change the status of all items to inactive as soon as the last date is due in SharePoint.
 
How can I achieve this?
 
dKayt
Categories:
  • Korhanh Profile Picture
    Korhanh 15 on at
    How to write my Update item
    Hello

    I created and tested a workflow, and I recommend working with data that has a specific CustomerID.

    1. Data Retrieval: First, I used the Get Items action to retrieve data with CustomerID 566.

    2. Variable Initialization: Next, I added an "Initialize variable" step and defined this variable as an array.

    3. Date Formatting: In the "Apply to each" step, I extracted the relevant dates using formatDateTime(items('Apply_to_each')?['Date']).

    4. 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').

    5. 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.

    6. 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.

     
     
     
     
     
     
  • dkayt Profile Picture
    dkayt 449 on at
    How to write my Update item
    Hi Korhanh,
     
    thanks for replying.
    I think I need to be more specific: as long as any date from the CustomerID has not yet passed, the status remains ‘active’ as soon as the recent date is ‘due’, which sets all statuses to ‘inactive’ at the same time. 
    Do you have a suggestion?
     
    Regards, dKayt
  • dkayt Profile Picture
    dkayt 449 on at
    How to write my Update item
    Hi, 
     
    thanks for replying.
    Let me show you how my flow actually looks like:
    The trigger works, but I don't know how to change the Status (active -> inactive) of all CustomerID with the same ID at the same time when the last Date is due.
    Do you have any idea?
     
    Regards, dKayt
  • mmbr1606 Profile Picture
    mmbr1606 10,429 on at
    How to write my Update item
    hey
     
    you would need to use Power Automate for it with a recurrence trigger set to daily who checks the dates and if a date is passed update the item and set the status to inactive.
     
     
    if my reply helped please mark as verified answer,
     
     
    cheers
  • Suggested answer
    Korhanh Profile Picture
    Korhanh 15 on at
    How to write my Update item

    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.

    1. Schedule the Flow: Set the flow to run daily (or at your preferred frequency).

    2. Retrieve Items: Fetch all items from the SharePoint list.

    3. Loop Through Each Item:

      • Use the Apply to Each action to iterate through the retrieved items.
    4. Compose Condition:

      • Implement the following expression to check the date:
      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.

    5. Condition Check:

      • If the result of the compose condition is true, change the item's status to "Inactive."
    6. Update Item:

      • Update the item's status to "Inactive" if the condition is met.
     
     
     
     
     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard