Skip to main content

Notifications

Power Automate - General Discussion
Answered

Create a condition to check if attachments exist and only add new attachments.

(0) ShareShare
ReportReport
Posted on by 15

This flow copies the item and its attachments from one list to another, and also updates the migrated list when modified. The problem I'm having is that when someone adds a new attachment on the source list, its being added on the migrated list but the flow shows failed as it's also picking up the existing attachments. Looks like I need to add a condition to check and ignore the attachments that exist and only add the new ones when the source is modified. Would appreciate your assistance, thank you.

 

Paulcofla_1-1710051142300.png

 

  • Verified answer
    Paulcofla Profile Picture
    Paulcofla 15 on at
    Re: Create a condition to check if attachments exist and only add new attachments.

    Awesome, thank you very much for the prompt response!

  • Nived_Nambiar Profile Picture
    Nived_Nambiar 17,074 on at
    Re: Create a condition to check if attachments exist and only add new attachments.

    Hi @Paulcofla 

     

    See the demo flow which helps to add attachments to a new list from existing list when item is created /Modfied.

     

    Assume we have two list - List12 and List13. The requirement is when item is created/Modified in List12 , item should be created/Modified in List13 respectively This flow would be with respect to attachments.

    see below

    1. use trigger 

    Nived_Nambiar_0-1710078764464.png

     

    2. use get attachments to get all attachments from a list item in list 12

    Nived_Nambiar_1-1710078813084.png

     

    3. Get items from List13 corresponding to item created/modifed in List12 if available.

    Nived_Nambiar_2-1710078856035.png

     

    (Here title is my unique identifier)

     

    4. Use condition to check whether the items are present as output from get items 

    Nived_Nambiar_3-1710078918500.png

     

    Expression - 

    length(outputs('Get_items')?['body/value'])
     
    If condition is True-
    Then item is created in List13 and attachments are also added from item in List12 to List13.
     
    Nived_Nambiar_4-1710078974762.png

     

     

    if condition is False- 

     

    in No branch do the following

     

    a. use get attachments to get details of attachments from List13 

    Nived_Nambiar_5-1710079037721.png

     

    Expression to get id -  first(outputs('Get_items')?['body/value'])?['ID']

     

    b. use apply to each to loop output of attachments obtained from get attachments details from List12.

    Nived_Nambiar_6-1710079111721.png

     

    Within the loop try like below

     b1- use filter array to check whether item in List12 is present in List13 or not ?

    Nived_Nambiar_7-1710079179218.png

     

    Nived_Nambiar_8-1710079202269.png

     

    Nived_Nambiar_9-1710079249009.png

     

    b2. write a condition like this to check output of filter has zero elements or not?

    Nived_Nambiar_10-1710079284173.png

     

    Expression -  length(body('Filter_array'))

     

    If condition is satisifed- follow the actions in Yes branch- 

    Nived_Nambiar_11-1710079346724.png

     

    Nived_Nambiar_12-1710079386924.png

     

    Next use add attachment  to attachment not present in List13

    Nived_Nambiar_13-1710079431625.png

     

    Expression -  first(outputs('Get_items')?['body/value'])?['ID']

     

    Nived_Nambiar_14-1710079485135.png

     

    Nived_Nambiar_15-1710079509956.png

     

     

    This is the design---

    Hope this helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

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,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard