Forum Discussion

jecon's avatar
jecon
Copper Contributor
Apr 26, 2022

Mirror Between document libraries based off Choice Column

Hello everyone,

Haven't been able to figure this out:

 

Scenario:

2 Sharepoint sites,

Site1 - DocumentLibrary1

(Site with no guest access for document uploads)

---

Site2 - DocumentLibrary2

(Site specifically for external guest access and viewing documents, basically a document portal)

 

I need to trigger the flow to copy files from Site1 to Site2 based on a status column, including nested folders.

 

In Site1, I have a choice column with status Shared/Not Shared which I use in my trigger condition.

 

Here is what I have so far:

 

I am stuck on the logic on how to move forward, how do I create the folder structure if it's not present and include it here?

Also I tested the flow in its current form and the trigger condition seems to not be working, the flow just hangs on the test, no error is given.

 

Any ideas or help are appreciated.

 

Thanks.

 

  • Update to this seeing as no one seems to know how to help:

     

    As there might be someone looking for this in the future I'll include the solution here.

    Good luck stranger, google is your friend!

     

    I resolved it myself with the following flow structure:

    • I needed to use the following expressions for the folder path in Copy File step:

    take(triggerOutputs()?['body/{Path}'],sub(length(triggerOutputs()?['body/{Path}']),1))

     

    • Made sure that the create folder step only runs if the folder is not present, and a join with a split function in the expression to take the file path without the root document library folder part and join it again:

    join(skip(split(triggerOutputs()?['body/{Path}'],'/'),1),'/')

     

    Then the copy file runs again and copies into the created folder.

     

    The issue with my trigger condition was that I included spaces once I removed them it worked perfectly:

    @equals(triggerBody()?['ExternalSharingDocuments']?['Value'],'Shared')

     

    Finally, I will create a separate delete flow for any "Shared" documents deleted in the source library to delete them in the document portal.

     

    Hope this helps someone.

     

     

  • jecon's avatar
    jecon
    Copper Contributor

    Update to this seeing as no one seems to know how to help:

     

    As there might be someone looking for this in the future I'll include the solution here.

    Good luck stranger, google is your friend!

     

    I resolved it myself with the following flow structure:

    • I needed to use the following expressions for the folder path in Copy File step:

    take(triggerOutputs()?['body/{Path}'],sub(length(triggerOutputs()?['body/{Path}']),1))

     

    • Made sure that the create folder step only runs if the folder is not present, and a join with a split function in the expression to take the file path without the root document library folder part and join it again:

    join(skip(split(triggerOutputs()?['body/{Path}'],'/'),1),'/')

     

    Then the copy file runs again and copies into the created folder.

     

    The issue with my trigger condition was that I included spaces once I removed them it worked perfectly:

    @equals(triggerBody()?['ExternalSharingDocuments']?['Value'],'Shared')

     

    Finally, I will create a separate delete flow for any "Shared" documents deleted in the source library to delete them in the document portal.

     

    Hope this helps someone.

     

     

Resources