web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Compare attachments in...
Power Automate
Answered

Compare attachments in the list and attachments in the JSON.

(0) ShareShare
ReportReport
Posted on by 112

Hi,

1. I have collected the attachments in the array from the list(ID =1) .

2. I am passing the attachments in the JSON format from the attachment control and in power automate, I have converted those attachments to one more array.

3. Now I tried to compare both attachments. Both arrays are having same attachments.

My issue is comparing fails. I am using the following type of action in power automate.

Sathya2_0-1644151914559.jpeg

Both the arrays are having the same attachments, actually I should not get any item in the final array. But I am getting all the attachments in the final array which I am comparing.
will the content-type and content strings change after saving to the list ?

 

 

Categories:
  • Mister_Shaik Profile Picture
    1,008 on at

    Hi @Sathya2 ,

     

    Can you explain the case scenario in a little more detail?

     

    Is the flow a Power App triggered one, and you're passing the attachments to flow and trying to compare the attachments passed from app and existing attachments of item by using "Get item"?

     

    In that case, are you comparing just the names? If yes, then I assume that you've already used Select action or some other process to get all the names to the 2 arrays for comparing, then what you're doing should work!

     

    Please let me know if my assumption if wrong, and provide additional details on your issue so that the community can assist you better 🙂

     

    Kind Regards,

    Shaik Sha

  • Sathya2 Profile Picture
    112 on at

    Hi, Thanks for the reply

    Your assumption is correct.

    After appending all the attachments to the array, the array schema will look like below:

    I am comparing the below things.

    {

    "Name" : "",

    "Content":{

    "$content-type":"",

    "$content":""

    }

    }

     

    My Array1 attachments and Array 2 attachments are same. I am comparing the similar attachments. In that case, the final array which I used to get the non matching attachment should not contain any items but the condition expression getting failed and adding all the attachments to the final array.

  • Verified answer
    Mister_Shaik Profile Picture
    1,008 on at

    Hi @Sathya2 ,

     

    Assuming that you just want to compare the "Name" of the attachments and collect all the unique or newly added attachments into a array, this is how it'll look,

     

    1. Get attachments from Power App and parse json
      1. trigger and parse json.PNG
    2. Using Select  action, get all attachment names into an array
      2. Power App attachments.PNG
    3. Get all item attachments and similarly save their display names as another array
      3. item attachments.PNG
    4. Now compare if any item from one array is not in another, if yes then append to an array variable
      4. conditon.PNG

     

    Here are my test run results

    • Power App attachments passed
      PA Attachments.PNG
    • Existing attachments in SharePoint list item
      SP attachments.PNG
    • Flow result to identify unique/new attachments
      result.PNG

     

    Hope I'm not wrong in my assumptions and this helps you 🙂

     

    Kind Regards,

    Shaik Sha
    ________________________________________________________________________

    If I have answered your question, please mark the post as Solved.
    If you like my response, please give it a Thumbs Up.

  • Sathya2 Profile Picture
    112 on at

    Hi, thanks. Your solution worked.

    But can you suggest me any idea to compare the entire things as per the below schema.

    {

    "Name" : "",

    "Content":{

    "$content-type":"",

    "$content":""

    }

    }

  • Mister_Shaik Profile Picture
    1,008 on at

    Hi @Sathya2 ,

     

    The schema that you're showing is of object type and it's difficult to compare and match objects in a flow. 

     

    The alternate solution would be to store the entire schema that you're showing as an individual string inside an array, that would be same for items from Power App and SP list item attachments. Then you can use those strings to compare and search for unique items. Also do note that you'd have to trim and remove the whitespaces and newlines to avoid any mismatch because of those.

     

    Unless is absolutely necessary, I'd suggest to stick with one property to compare, like Name of files.

     

    Kind Regards,

    Shaik Sha

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard