Can "Upload file from URL" destination be a SharePoint folder?

7459
34
Jump to solution
06-20-2023 02:00 PM
Tiff
by
Frequent Contributor

I have a flow set up that starts with a Survey123 submission trigger, generating a feature reporting and then uploading that to OneDrive and subsequently sending an email.

This project is highly collaborative and I would like the reports to reside in a shared SharePoint folder rather than my personal OneDrive. I have not been able to find any resources on how to do so/whether it's possible using the Destination File Path parameter. Any assistance is appreciated!

34 Replies
Tiff
by
Frequent Contributor

Thank you, @Beard_Greg! I'm testing this out now and hoping you or @SeanKMcGinnis could offer some more insight. I am realizing now that the HTTP/Situation Report operation in Premium only. Unfortunately I don't think I have premium.

Am I able to perform the "Create file" action without the Situation Report operation / Is there another way to get the feature report into SharePoint with a similar workflow? Of course, followed by getting the URL/PDF to send in an email.

I see Greg is using the "Get attachments" action as well. I'm not entirely sure what "List Name" refers to, but it is only letting me put in the general site address (not the specific folder where the PDFs will live).

0 Kudos
Beard_Greg
Occasional Contributor

Apologies for the confusion. The "Get Attachment" was an ArcGIS action, not a SharePoint action.

Unfortunately HTTP and ArcGIS' "Get Attachment" are both premium products from Power Automate. I'm not sure of another method. 

If you find a way to get the attachments. I believe you can download the attachments straight to the email without going through SharePoint to "Get Attachments" again. If that makes sense? You should only have to "Get Attachments" once. 

0 Kudos
Tiff
by
Frequent Contributor

Hi @Beard_Greg, thanks again! Good news - I was able to get premium licensing assigned. I think I am struggling a bit with the HTTP action which seemed to not work for you as well. I used GET as instructed by Sean, but in the Survey123 forum post you linked, Ismael uses POST and also generates a token that I'm not able to replicate on my end... also, when I test the flow it seems to be stuck on the spinning wheel.

So looking for alternative options... For the Get Attachments action, can you guide me on how to fill in the List Name and Id? "Create file" action is a lot more straightforward so I can type in the folder path, but I don't think that action alone is sufficient in getting that file into an email (not 100% sure).

0 Kudos
Beard_Greg
Occasional Contributor

Oh Very Exciting! I actually just needed to build something similar. Below is what I just tested and it worked. I used what @IsmaelChivite suggested, but replaced HTTP with ArcGIS Get Attachments. If you need more of a "why", definitely use his page. Survey123 Tricks of the Trade: Working with attachments in Microsoft Power Automate 

Here is just a quick overview, and I'll dive into each one. I'm not as fancy as Ismael with gifs.

Beard_Greg_0-1689824236113.png

Step 1: Set up your trigger. For us, that is "When a survey response is submitted". You should be able to do the drop down for your feature layer. If the drop down isn't working, I've found, going to Data -> Connections and then refresh your connection, works well. By default everything else is "Yes" and I don't change it.

Beard_Greg_1-1689824381629.png

Step 2: Create your array variable using "Initialize variable". Be specific in your Name especially if you ask multiple questions with file uploads as you will be referencing the name later. Leave "Value" blank. This step is needed because Survey123 file uploads can be single or multiple (If you're using Connect you'll want the appearance column = multiline to allow multiple attachments).

Beard_Greg_2-1689824606518.png

Step 3: Create your loop to get all your attachments. Even if you only have one file uploaded, I do not believe it changes this step any. Since this step has multiple parts, I'll break it into 3a, 3b, 3c, and 3d.

Beard_Greg_4-1689824944435.png

Step 3a: Create loop using "Apply to each". Use the dynamic content option to find your available features from the Survey123. Dynamic content has a search function that is awesome if you have a lot of file upload questions. You want feature attachments + name you gave the question. For me that is Upload_Structural which was located at the bottom of my list (second image). 

Beard_Greg_6-1689825245044.png

Beard_Greg_7-1689825664659.png

Step 3b: Use ArcGIS "Get Attachment" to extract your file uploads. Use the dropdown to find your feature layer which should be the name of your Survey123. Your objectID is pretty standard. It is searchable in the dynamic content (feature result objectId). For Attachment, you'll want the feature attachments + name you gave the question + id, so for me that is feature attachments Upload_Structural id (3rd from the bottom using the picture above). 

Beard_Greg_8-1689825959582.png

Step 3c: Add your attachments to your array using "Append to array variable". The Name drop down will be the name your provided on Step 2. For Value, Ismeal provided the below with the underlined section being unique the ArcGIS not HTTP

{
  "ContentBytes": <Your ArcGIS Get Attachment: Attachment contents. Build using an Expression>,
  "Name":<Your feature attachments name goes here. Get from Dynamic Content>
}

Beard_Greg_9-1689826324606.png

In the above image, body is the Get Attachment Attachment contents. If you named your ArcGIS Action something else, it will be "Action Name" in gray. The below image shows I only have one ArcGIS Action variable available (yellow). Make sure you do not delete the comma at the end of ContentBytes.

The Name is the file name provided by the Survey123 trigger (green). Using dynamic content, for me it was "feature attachments Upload_Structural name".

Beard_Greg_10-1689826593704.png

Step 3d: Add files to SharePoint using "Create File". Use the drop down for site address and folder path. You can use some of variables to make unique path. Be sure to add forward slashes "/" to create subfolders. For my file name and content, I used the same variables listed in Step 3c. 

Beard_Greg_0-1689827714328.png

Step 4: Send email. We are an office 365 Agency so this is what I'm using. If you are too, be sure to click the button in the attachments section to make it "switch to input entire array".  Add your array variable to the attachments section. I ask a question where I require their email so it sends the data to them. 

Beard_Greg_1-1689827841383.png

Hope this helps! If you have multiple questions with file uploads you'll need to repeat Steps 2 and 3 per question. Good luck!

 

Tiff
by
Frequent Contributor

Hi @Beard_Greg, thanks for this! I really appreciate the detailed walkthrough. One quick clarification - I realize now that with your workflow it is obtaining attachments from the feature layer. In my case, I am actually generating a feature report using the new Power Automate action called "Create report". It will be created as a PDF and ideally I want to upload to a specific folder in SharePoint and then grab that file and email it out. Would this workflow look completely different? (It also does not feel like it should be this difficult...)

0 Kudos
Beard_Greg
Occasional Contributor

Oh no! Sorry about that. You got me curious so I looked around and found some things and built one. Once again, @IsmaelChivite coming to the rescue.

Main Source for flow (Source 1): Survey123 Create Report action in Microsoft Power Automate (Preview)

Answered SharePoint Portion (Source 2). Ismael suggested transferring from OneDrive to SharePoint: Use Power Automate with Survey123 and SharePoint 

So based on what I found, it wasn't quick and easy to get the PDF report into SharePoint. However, it was super easy getting it into OneDrive. The flow I will be showing: When a Survey123 is submitted, create a report, download report into OneDrive, copy the data from OneDrive into SharePoint, sends email with attachment, deletes OneDrive file.

Overview:

Beard_Greg_0-1689915510794.png

Step1: When a survey response is submitted. Choose your survey123.

Step 2: Create Report. For this to work, you will need to have already created a report template on the Data tab on the Survey123 Website. Source 1 has a video. First two questions are your Survey123 information. If you've create a report template, it should be listed as a drop down. Object ID is the ObjectID of the survey123 so that should be simple. Report Name is what you want to call the file. Make sure it is unique! Change the format to PDF.

Beard_Greg_2-1689915856649.png

Step 3: Upload Report into OneDrive. Source 1 does a really good job explaining this. I chose to put mine in a specific folder. Hypothetically if this works perfectly every time, this folder will always be empty. I changed my Overwrite output to "Yes" just in case, but it works with No as well. "Yes" helps with testing. It's transferring to SharePoint so it doesn't matter too much especially if you give the file a unique name. 

Source URL = Use URL - URL of the first result file from Dynamic Content 

Destination File Path: Where you want it saved. I added Name - Name of the first result file from Dynamic content

Beard_Greg_4-1689916207548.png

Step 4: Get the File Content so that you can transfer to SharePoint. 

File Path: Use the dynamic content Upload file from URL - Path

Beard_Greg_5-1689916604739.png

Step 5: Create File (SharePoint). Site Address / Folder Path for where you want it saved.

File Name you have some options, but I just went with the name generated by Step 3. 

File Content: Use Dynamic Content to find Get file content using path - File Content (second image).

Beard_Greg_11-1689917982910.png

Beard_Greg_7-1689917016066.png

Step 6: Send Email

Attachment Name / Content: I used the same fields I used in Step 5 for creating the file in SharePoint

Beard_Greg_10-1689917176891.png

Step 7: Delete file (OneDrive)

The ID is from Upload file from URL - ID (The unique identifier of the file or folder)

Beard_Greg_9-1689917086094.png

Hope this helps!

0 Kudos
Tiff
by
Frequent Contributor

You are AWESOME! Thank you @Beard_Greg! I initially had the workflow set up this way to work in OneDrive so about 80% of the way there, but I wasn't having much luck with the SharePoint aspect. I didn't come across that new forum post about SharePoint - so thanks for sharing! It also confirms that it's not as easy as it should be, but this is a great workaround and I only had to add a couple of steps to my flow. I think I am all set!

0 Kudos
Beard_Greg
Occasional Contributor

Yeah, I reread your initial request and realized toward the end you already had most of it built. Figured for the next person to continue though. Great job!

0 Kudos
MichelleWilliamsERM
Frequent Contributor

Thank you so much for your directions, this is exactly what I was looking for.  (I have a hint for those going forward & a cry for help at the bottom)

Here are some new options used in May 2024 - You can use successful trigger data to run your next flow. MichelleWilliamsERM_0-1715212777403.png

I could overwrite the file in OneDrive, but I had to delete previous files in the SharePoint to use the triggers. 

 

HELP - I'm getting a weird error message and I'm still researching it, if anyone knows what it is, I'd love to know how you fixed it. My flow matches Beard_Greg's. BUT something's changed since the document was created. Thank you!

MichelleWilliamsERM_2-1715212989519.png

 

 

 

 

0 Kudos
RobertAnderson3
MVP Regular Contributor

I've started noticing issues with the Word Docs as well, when I run them manually from the Survey123 website and they open in the web browser I get this issue, but if I download it and open it in Desktop it's fine. 

With the files I get from my flows, they're placed into a Teams folder and it seems they open fine from there, in Teams, the Desktop app or even in the browser version.

I'm wondering if it's a bug that should be reported to Esri Support..

0 Kudos