I have created a flow that extracts information from email attachments using an AI Model, then moves the attachments to a Sharepoint folder using the extracted data as the folder name. The problem is that it only copies one of the two files to the appropriate folder. The other file doesn't have the AI form data, so it doesn't get scanned, but it needs to go into the same folder as the other file. Here's my flow:
So the folder that gets created is "Submittal Number". FILE1.PDF has the form data that gets exctracted via AI. FILE2.PDF is a companion file, but doesn't contain any of the form data. When I run the flow, here is how the file structure comes out:
/Shared Documents/Administration/Submittals/Submittal Number/FILE1.PDF
/Shared Documents/Administration/Submittals/FILE2.PDF
Any help would be much appreciated!
Solved! Go to Solution.
Initialize a variable of type array before the loop. Then use the loop only to make the AI extract and store the result in the array (Append to array action). Outside the loop create a Filter array action with filtering do not equals null. This should return the one number only.
Now create a new loop to go through each attachment and create file action with your storage string and the Filtered array result (you need to use first or integer pointer to ensure it us only one value!) and store the files.
That should work.
The issue is that the second pdf does not have the related data extract... and then the path is just as you state in the folder path hard coded without the AI extract.
You could use a create folder action first only on the first AI scannable file and use this path to sore the second doc in.
Then you have to make sure that always the first doc contains the AI scann info. Does the email always attachments always contain the same file naming?
Thanks. That is one of the first things I tried, but the problem I ran into was once I created the folder I couldn't figure out how to reference the new folder name in a new step without invoking the AI script again. That basically put me back into the same loop.
The filenames are sometimes different, but the form data is always consistent. Sort of like a cover sheet for a letter, but the letter is a separate attachment.
Initialize a variable of type array before the loop. Then use the loop only to make the AI extract and store the result in the array (Append to array action). Outside the loop create a Filter array action with filtering do not equals null. This should return the one number only.
Now create a new loop to go through each attachment and create file action with your storage string and the Filtered array result (you need to use first or integer pointer to ensure it us only one value!) and store the files.
That should work.
I think that's what I was looking for, but it keeps getting stuck on the second file. The first file processes fine, but when it gets to the second one, it throws an error and stops. I'm a bit new to this, so I may be missing something... here is the error for file #2.
Add a condition block action before the append to check whether the return value is not equals null. If it is true append the value else do nothing. That should work.
Almost there! Good suggestion on the condition block. I got that working, and the file creation works, but when I call the variable, it returns ["Folder Name"] instead of just Folder Name. How can I get rid of the brackets and quotes? Here's how it looks. The folder should just be called 07 41 13-4.1.
@PowerAppsWizard Thanks for all your help. I figured out the last part and everything is working. Just for record purposes, here's what I did:
After the append, I set an Initialize variable block to switch the Folder Name variable to a string. Then, a Compose block to remove the quotes/brackets which looks like this
replace(replace(replace(variables('FolderString'),'[',''),'"',''),']','')
Then I ran a Create file, using the Compose output for the new folder name.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
28 | |
27 | |
27 | |
20 | |
10 |