Hey. Everyone, April Dunnam
here. In this video, I'm going to show you how you can
use the file attachment capability of Microsoft forms and create a flow and
power automate that takes that information and the attachment and rates
that out to a list in SharePoint. This was a pretty highly requested topic
in the previous video that I did on moving Microsoft forms
data to Microsoft list. So I thought I would do a quick video
walking you through how we can now take those attachments and move those at
the same time into our SharePoint list, either as an attachment to the list item
or in a SharePoint document library, there's a few steps involved to this, but I'll bring it all down
for you right after this. [Inaudible]. Okay. First things first, let's see how we get the form set
up in Microsoft forms to handle file attachments. So I have a form that I created to get
information for session requests for a conference. So I've added single edit
text fields for first name, last name, and you'll notice what I have here. I have a profile picture field
where they can upload their picture. So you get a file upload in your
Microsoft forms. Just click, add new click on the drop down there,
and we'll see a new file upload option. And when you add one of these ads, there's a few different settings
that you need to configure. First. You have to choose how many
files to limit this field to. We can also choose these
single file size limit. We can set that to 10 megabytes,
a hundred megabytes or one gig. So just choose the option
there for your needs. And then that's really all we need
to do from the forms site itself. Next thing I did is I went into SharePoint
and I created a list that contains all of those fields in it. And we're
using the title field for the last name. I created a single line of text
for first name, job title, email, and session title, and that
profile picture file attachment. I want to actually attach that here
directly on the items. So as you can see, I've tested this workflow already. I have a file attachment in there is
the picture in the attachment that was saved from the Microsoft form
to get this all synchronized. So I'm working though. We
need some power automate, so let's go over the power
automate click on my flows. I'll click the new flow option and
choose the automated cloud flow. So I'll give our flow name.
So call is power platform, bootcamp sessions, and then for
the trigger, we'll select the, when a new response is
submitted into Microsoft forms, click create I'll choose my
forum for the dropdown here. The power platform bootcamp
called for speakers, and now we need to get the response
details. So we'll do a new step. I'll just type get response. And the first one that pops up there is
Microsoft forms get response details. That's what we want. We'll choose the form again from
this dropdown and for the response ID, we'll point it to the item from the
trigger which we have here in our dynamic content. It's
the response ID fields. Now the next thing I'm going to do, I want to create an item in the SharePoint
lists to hold all of that static data. So not the profile picture of any
of that, just the first name, last name, and all that static information. Then we'll go back in after that and add
that attachment. So to create the item, we'll add a new step, do a search for create item and we'll
choose these SharePoint creates item action. I'll select the training site from the
site address drop down and I had a list called power platform,
bootcamps submissions, and that's where I'm going
to be storing the data. Now I'll just map my properties. [Inaudible]. Now is we're actually going to do the
work where we're going to pull that attachment for the profile
picture from this form. So there are a couple of steps involved
here that you might be tempted to just create a new stuff, search for, add
attachment, and choose to SharePoint, add attachment action, and just point the file name and file
content properties to this profile picture field from our Microsoft
form. This isn't going to work though, because that object there does it
store the file content or the file name that we need to
actually pull in there. We need to go do two
separate actions to get that. We need to first extract
out the name of the file. Then we need to actually go and make a
call from where it's actually stored. So that leads us into the first question
when we're leveraging that attachment capability in Microsoft forms, where
is that physically storing the file? Well behind the scenes, when you
configure it and set up a form, leveraging the file attachment capability, it's storing the files in the one drive
for business account of the person that created the form. So I set up that
power platform, bootcamp form. And if I go to my one drive
for a business account, I see what it does is it
creates an apps folder. And within that apps folder, we
have a Microsoft forms folder. If we keep drilling down now into the
Microsoft forms folder, let me see. We have another folder which is
associated with the name of my form. So every form that you have,
if it includes an attachment, it will be shown here in this
folder. So apps, Microsoft forms, and then your form name. Now, if
we keep drilling down into this, I'll go into this folder
for my form. We see, we have question and question one, these
are the two attachments I have now. I only show up one, but
if we go back to the form, they actually do have another attachment
for session abstract and resources. So unfortunately the names aren't super
intuitive it's really goes by the order in which you add the
file attachment field in. So if you do have multiple
attachment village in our forums, you kind of have to know which one
you added first for these names of the folders, or they're stored to make sense. Now I happen to know that I added
the profile picture one second. So that means it's probably this question
one folder. So if I dive into that, I will see the two pictures that I know
I have uploaded in my testing so far. So we're going to need
to know this file path, to be able to look up the contents
and retrieve that of this file, but we actually need to do something
before we even mess with retrieving this file from our one drive. We need to get the name of the file
because the only way to look up and find that file is with having that
complete path with the file name. So how do we get the name of the
file before we can figure that out? We need to actually save what we have
so far, and we want to submit a test. So we actually want to run through
submitting an item in that form so that we can see the outputs of that.
So let's go back to our forum. I'm going to open it up and preview,
and I'm going to feel something else. Let me upload an image
here and then click submit. Now we'll go back to our flow and we'll
click out of here and we'll look at the run history so I can see it ran. So you want to inspect the run
history now and expand out this, get response details, action
that we see succeeded. This is where we'll find out the format
that we need to be able to extract the name of our image. So if we look at the profile picture
property here in our get response details, you see that object there. That field is actually a
block of Jason. So you see, I have a property called
name with a value. We have another property called link, which is actually where
the file is stored. We have other properties for
ID type size and reference ID. This is why we couldn't just
point that field directly in our add attachments action, because that's
not just a file content or a file name. We need to do something
called parsing this Jason, to extract out just the information we
need in this case, the name of the file. So this is the whole reason why we had
to test it. We needed to get to this. So what we're going to do is we're going
to copy what's in this profile picture attachment field that we see
here, this block of Jason. And now we're going to go back into our
edit mode and we need to add an action in here to parse this. So let's add
a new step and do a search for parse. We want this data operations parse Jason
action for the content property here, when to click in that box. And this is where we want to
point to our attachment fields, which in my case is profile picture. Now we need to give it a sample
of what the Jaison will look like. That's why we tested
it. And we copied that. So what we'll do is we'll click
generate from sample and we'll piece. What we copied in here
now just click done. And now we have a way to get to that name. Now we can do that call to one drive
for business and pull the file content. So what we'll do is we'll click new step. We'll do a search for gets file content
and we'll choose the get file content using path for the one drive
for business connector. Now this needs a complete file path. So we'll have to go back to what we were
looking at earlier with the one drive. And we need to look at this total file
path and type that in manually there in that one drive for business action, I've
already typed this out and I'm lazy. So I'm just going to
paste that right in there. So you want to start it with a forward
slash then you'll have the name of the first folder, which has apps or another forward slash
the Microsoft forms folder another forward slash and the name of your form
in a final forward slash and the name of the folder where your field
that has the attachment is now, the last thing to do is now we
need to pull in the file name. So we have a final Ford slash, and
this is where we need to pull that in. And we need to use an expression
and power automate for this. Now you notice here in that dynamic
content window, under the parse, Jason header, these are all those properties that
we had from that block of Jason. So the one that we're trying to
get to is this name, property. That's where the file name is store. Now I can't just click on that and then
have that be the name of my file in the file path, because it
recognizes this as an array. So we need to use a function called
first to get the first object there that contains the name. So I'm going
to click on the expression tab. We're going to use that first function, and then we're just going to
pass in the name of that name, field from our pars Jason action.
So let's click okay on this. So we see that populate there
that I'm a compulsive saber. So I'm going to save this
one more time, right? There's only one thing left to do. We need to actually add that attachment
now because we have everything we need. So all that we're going to do
now is click a new step again, do a search for add attachment, choose
these SharePoint, add attachment options, choose the site address and listen
to them again. Then for the ID, we'll point that to the ID
from our Crete item action. And now it's time for the file name.
So we'll do that same expression. We'll switch over to the expression
option piece, set in click, okay for the file content. And you'll
see in that dynamic content window. Now we have that gets
file content using path, and we have a file concept property
that we can pass it. All right. That is all that is needed. So let's
save this and let's run the test. So I'm going to jump back over to our
form, fill it out here, upload a picture, click submit. Now let's
jump back over to our flow. Let's look at that run history. See we
have a successful run three seconds ago. So if we kind of peak at what's going
on here, if I look at my parse, Jason, I can see that data being populated there
with the name because he gets a file content succeeded. So if you
look at one drive, for example, I see that new picture was
added just a few seconds ago. And final moment of truth. If
I go to my SharePoint list, I'll see there is the item. And if I
opened that up, I see the attachment. I can click on that and it opens right up. We can make a simple modification to
this if we didn't want to add this as an attachment, but rather in a document
library, all we'd have to do in that case. If I go back to the edit mode here is
replaced the add attachment action with the create file action for SharePoint
point that to the site address and the folder path. So I'll just choose this
generic share documents, library, and same thing for the file name. So
they will use that expression here, getting the name from our parser Doosan
action and the file content from our goods content using file path one drive
connector. So now if I click save, this should be in two places and
rather than submit that form again, I'll just do a test. So I'll use
our nifty testing function and flow. I'll do with a recent trigger
click test. They ran successfully. So let's go back to SharePoint,
look at that document library. And there's the profile picture. That just one more thing that I want
to point out before I let you go. If you recall in the options here
in our file attachment on our form, we had the option to
have a file number limit. So if you did set that to maybe allow
someone to upload more than one file in the attachment, this will slightly change the process
that we just went through in your flow. So really we can do
all of the same things. The main thing that would change here
is in the gets file content path and the add attachment actions here. If you allow multiple file
attachments in that field, you wouldn't want to use the first
function because that's only returning one item. Instead, you had pointed
directly to this, you saw name, and when you do that and I'll just
show you real quickly, what happens, it's going to wrap your add attachment
action insight and apply it to each. So this will do a loop for you, looping through all the attachments
and getting that name, property, and same thing with the
GEDs file concept from path. Don't use the first point directly to
the name so that I can do the looping through all the different
attachments there. All right, well that pretty much wraps it up. If
you found this helpful, do me a favor, like subscribe, share that I'll
catch you in the next video.