for Microsoft Power Automate and Azure logic apps

By Jay Goodison

23rd October 2019

New Power Automate Action: Add to Archive (ZIP)

We’re really excited to release another new Power Automate action for the Encodian Power Automate Connector! The ‘Add to Archive (ZIP)‘ action enables you to add one or more files to an archive package (.zip file), very cool!

Please follow this guide which details how to retrieve a collection of documents from a SharePoint library, add them to an archive package (ZIP file) before uploading the new archive file to SharePoint.

Not forgetting! Once you have created the ZIP file you can do whatever you need to do with the archive file using the power of Microsoft Power Automate!

1. Create a new Flow using the ‘Automated — from blank‘ option

2. Enter a name for the Flow, select the ‘Automated — from blank‘ SharePoint trigger action and click ‘Create

3. Add a ‘Get files (properties only)‘ SharePoint action

3.a. Site Address: Enter the location of the SharePoint site where the target files are stored

3.b. Library Name: Select the source SharePoint library containing the target files

3.d. Click ‘Show advanced options

To retrieve a collection of specific files we’re going to use an ODATA filter query. The query will be setup to obtain a collection of documents where the ‘Action‘ column is set to ‘Add to Archive

3.e. Filter Query: Add the following query Action eq ‘Add to Archive’

4. Add an ‘Initialize variable‘ action

4.a. Name: set to ‘Files

4.b. Type: Select ‘Array

5. Add a ‘Get file content‘ SharePoint action

5.a. Site Address: set as per step 3.a

5.b. File Identifier: Select the ‘Identifier‘ property from the ‘Get files (properties only)‘ SharePoint action

Power Automate will now automatically create an ‘Apply to each‘ loop and move the ‘Get file content‘ action into the loop

6. Underneath the ‘Get file content‘ action, add a ‘Append to array variable‘ action

6.a. Name: Select the ‘Files‘ variable created in step 4

6.b. Value: Enter the following JSON

{
    "fileName":,
    "fileContent":
}

6.c. Place the cursor after “fileName”: and select the ‘File name with extension‘ property from the ‘Get files (properties only)‘ SharePoint action

6.d. Place the cursor after “fileContent”: and select the ‘File Content’ property from the ‘Get file content‘ SharePoint action

7. Underneath the ‘Apply to each‘ loop, add an Encodian ‘Add to Archive (ZIP)‘ action

7.a. Filename: Enter a name for the archive package (ZIP file)

7.b. Click the ‘Switch to input entire array icon

7.d. Documents: Select the ‘Files‘ variable

NOTE: If you experience issues executing the ‘Add to Archive (ZIP)‘ action please review the following article: https://www.encodian.com/2019/12/errors-processing-document-arrays/

8. Add a ‘Create file‘ SharePoint action

8.a. Site Address: Set to the value of the SharePoint site which contains the target document library

8.b. Folder Path: Set to the value of the target SharePoint folder

8.c. File Name: Select the ‘Filename‘ property from the ‘ Add to Archive (ZIP)‘ Encodian action

8.d. File Content: Select the ‘File Content‘ property from the ‘ Add to Archive (ZIP)‘ Encodian action

9. The completed flow should follow this construct:

10. Now let’s test the Flow! Select ‘I’ll perform the trigger action‘ and click ‘Save & Test

11. Verify the Flow has executed successfully

12. Verify the archive (ZIP file) has been created successfully:

Finally…

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!

2 Comments

  1. Adam Cooke says:

    Hello, I tried doing these steps, and I’m receiving an “invalid json” whenever I attempt to save power automate. I copy and pasted exactly as you have written, but I’m not sure if I should have typed it on my own, or if there’s another issue.

    1. Jay Goodison says:

      Hi Adam,
      Please email support@encodian.com how will be able to advise
      Thanks Jay

Leave a comment

Your email address will not be published. Required fields are marked *