Power Automate - When Creating a file in a Document Library, check if the file exists, if it does send link to file to submitter

Anonymous
2023-03-23T18:23:37+00:00

I have a Document Submission SharePoint List that users can submit an item with a document attached. I then have a Power Automate flow that will Create a File based on the attached file in the list and copy the associated metadata over. This part is created.

However, if the file already exists in the library, the flow will fail on the Create file action with "A file with the name (doc name) already exists. We wouldn't want people overwriting the existing file anyway, so that is a good thing.

People will be submitting a Visio diagram and a Word document that will have the same display name, so I need to make sure the file extension is also considered when checking.

I'm not sure the best way to go about this. I was thinking either of these options:

  1. Check to see if the file exists in the Document Library in advance of the failure and send an email or Teams notification to the submitter
  2. If it fails with this error, send the actual error plus a link to the file in the library to the submitter via email so they can compare it to the one they are submitting.

I would need assistance building out either of those scenarios if someone has some examples to share.

Thanks,

Shawn

Microsoft 365 and Office | Install, redeem, activate | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2023-03-30T04:40:54+00:00

    Dear Shawn,

    Thanks for your updates and kindness.

    Welcome to post a new thread on our forum at your convenience if you encounter any issues.

    Thanks for your effort and time!

    Sincerely,

    Cliff | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-03-29T19:40:14+00:00

    Thanks again Cliff!

    I really appreciate your assistance with this flow. That got me to where I need to be.

    Thanks,

    Shawn

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-03-29T05:06:19+00:00

    Dear Shawn,

    Thanks for your updates and confirmation.

    I have re-created a flow based on your consideration for your reference. The flow will check whether the files in the document library such as DocumentLibrary and go to send emails to users or create the attachments in DocumentLibrary directly.

    Compose: join(body('Filter_array'),';')

    Condition: empty(outputs('Compose')) is not equal to true

    Result:

    Thanks for your effort and time!

    Sincerely,

    Cliff | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-03-28T15:14:54+00:00

    Hi Cliff,

    Thank you so much for mocking that up. However, I'm trying to avoid using Power Apps because it would require submitters to have a Power Apps license..at least from the info I've found: https://powerusers.microsoft.com/t5/Power-Apps-Governance-and/Users-need-license-to-access-SharePoint-custom-list-form/m-p/1562248#M6358

    Any Non-Power app suggestions?

    Thanks,

    Shawn

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-03-24T04:03:51+00:00

    Dear Shawn,

    I think that the best way is to use PowerApps to customize the list item form so that users can check whether the attachments exist in the Custom Approval library before they trigger the flow manually.

    If you have PowerApps in your environment, you can see the following example.

    Go to the DocumentSubmission list, click on Integrate>PowerApps>Customize forms to access PowerApps.

    Add a text input control by clicking on Insert>Text input. In my environment, it is TextInput1.

    Type the notification text such as "Please check attachments' names in the next screen!" on Default to notify users to go to the next screen to type the attachments' names and check whether they have existed in Custom Approval by a search box.

    Create a button such as Go to next screen for users to go to the next screen to check the attachments' names. Click on Insert>Button. In my environment, it is Button1. Type the formula Navigate(Screen1,ScreenTransition.Fade) on OnSelect on Button1.

    Next click on New screen and add a blank screen. In my environment, it is Screen1. Click on Data>click on + Add data>search SharePoint and click on SharePoint to connect Custom Approval to PowerApps.

    Then click on Tree view>click on Insert>Vertical Gallery to insert a gallery. In my environment, it is Gallery1.Select the gallery and select the layout as Title and subtitle and choose ThisItem.'File name with extension' in Subtitle2. Click on the first row of the gallery>insert Insert>Text input and type text "File Name and extension" on it and format it as you like. In my environment, it is TextInput2.

    Click on Screen1 and add a text input control and add a search icon to create a search box for users to type the attachments' names and check whether it exists in Custom Approval. In my environment, it is TextInput3 and Icon1.

    Select the gallery and type the formula Search('Custom Approval',TextInput3.Text,"{FilenameWithExtension}") on Items on Gallery1.

    Add a button such as Back to Submission Screen in Screen1 for users to go to back to the form submission screen to change the attachments if it is needed. In my environment it is Button2. Type the formula on OnSelect on Button2.

    Finally save the app and click on Publish to publish it to the DocumentSubmission list.

    Result:

    Welcome to share any updates when you have time if you need further help on this issue.

    Thanks for your effort and time!

    Sincerely,

    Cliff | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments