Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

how to check if attachment has been added or changed ?

(0) ShareShare
ReportReport
Posted on by 2
Hi,
 
I know I can check if a SPO list item has an attachment or not, but how do I check of a 2nd, 3rd,4th,... attachment has been added, respectively one of the attachments has been changed with  PowerAutomate flow ??

thanks alex.
  • David_MA Profile Picture
    David_MA 8,364 on at
    how to check if attachment has been added or changed ?
    Step six is the action that you can use to determine if the attachments have changed based on the AttachmentCount value. It gets the version history information from the flow run to the last version and returns true and false for the fields in the list as to whether the value has changed since the last version. 
  • AF-02100940-0 Profile Picture
    AF-02100940-0 2 on at
    how to check if attachment has been added or changed ?
    Hi David
     
    this makes sense ! thanks a lot !
    What is the purpose of step 6) actually ? 
     
    ciao alex.
  • David_MA Profile Picture
    David_MA 8,364 on at
    how to check if attachment has been added or changed ?
    I don't know of a way to figure out what attachment has been added or removed, but I can help you figure out if they have been changed. Do this:
    1. Add an integer variable to your list named AttachmentCount and set the initial value to 0.
    2. Create a workflow that triggers when the item is created and modified.
    3. Add a condition where Has attachments is equal to true.
    4. On the yes side of the condition (if it has attachments), add a Get attachments action and configure it to the list item.
    5. Add a compose action and use a length expression to return the number of attachments from the Get attachments action: length(outputs('Get_attachments')?['body'])
    6. Follow this with a Get changes for an item or file action configured to the list item.
      1. Configure Since to Trigger Window Start
      2. Configure Until to Trigger WIndow End
      3. Trigger Window Start and End are listed in the Dynamic Content
    7. Add another condition to check if the AttachmentCount field in step 1 is NOT equal to the calculated attachment count from step 5. You'll want to pass both values through an int expression to prevent any errors.
      1. int(triggerOutputs()?['body/AttachmentCount'])
      2. int(outputs('Compose_Count_Attachments'))
    8. If it is NOT equal, that means an attachment was added or removed since the last save.
    9. On the yes side of the second condition, you would add an Update item action to update the AttachmentCount from step one with the value generated in step five. 
    Your flow will look like this (with the exception of the last action to update the list item with the new attachment count):
    ​​​​​​​









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

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard