
Announcements
Hi all,
I have built out a flow whereby the user completes a form and the responses are saved into an SP list, the form responses through the automation is captured in a PDF file which is accessible through a "View Files" hyperlink in the list (which is being used by supervisors as a workbench) to review the item per ID and then click on view files to see the pdf responses from the form but also the attachments submitted through the form. I incorporated some neat things into the flow based on a couple of different resources. The sharepoint library that holds the attachments and the created pdf file from the flow is filtered based on the list item view files that is clicked on so that the supervisors and only physically looking at the pertinent attachments. I have the attachment enabled on the list so that if an item requires minor tweaks the user is able to use the attachment feature without the need to submit a new form and upload new attachments.
Long story very short, the flow is working. However, I need to enhance this flow or create another so that any time a new attachment is added to the list item, the flow looks to that change only and then looks through the sharepoint library, by comparing the two, it only "adds" the file that is in list but not library. Once it adds to the library it inherits the ID which is what the filter uses for the hyperlink. so that whenever the link is used all the attachments (original + new ones) are accessible. Can someone share how I may do this? I have been able to add files but the files are duplicating and now getting associated to the correct ID. Any guidance is greatly appreciated.
Are you storing the list item ID alongside the files in the SP library?
If so then you can easily compare by doing a Get files (properties only) action with an odata filter like ListItemID eq ID where ID is the list item ID from the trigger (when an item is modified). That should return a list of files.
Now you do Get attachments action and that will also output a list of files. Evaluate both lists with length() function and if they are not equal then you can do Filter array action and filter the attachments array for items that are not in the array from the Get files (properties only) action. and the resulting array, which may contain one or more files you can process through an Apply to each to get the content and upload into the SP library