cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Derek4
Helper III
Helper III

Store attachment array in SharePoint

Hello,

 

I'm building a simple flow,

First, the requestor fill the Forms and upload attachment;

Second, store the attachment in an array and send to approvers;

Third, if all approvers approve, create record in SharePoint, including the attachment.

 

my flow looks like this:

微信截图_20200916145323.png

 

So far, everything is OK, except for the last scope: create SharePoint record:

微信截图_20200916150007.png

 

 

 

what I'm trying to do in this scope is :

1. create a record in a SharePoint list (already done and OK);

2. create a new folder in SharePoint with the name: Requestor's name + department name + submission date;

3. store the attachments that requestor upload to the Forms to the newly created SharePoint folder (the attachments are already stored in array in my flow).

 

Appreciate any help in this, Thanks in advance!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@efialttes 

Yes, I have solved the issue, in an old way...

 

I use the same method that I used to append to the attachment array variable:

 

First, get file content using path (OneDrive for business)

Second, create file (SharePoint)

Third, put the above in an Apply to each:

微信截图_20200922113244.png

 

and it worked... in this old way...

 

I think the issue with using the attachment array variable is the wrong folder path I type in with Create file in SharePoint, I insert an "forms" in the folder path...

 

Thank you!

View solution in original post

12 REPLIES 12
efialttes
Super User III
Super User III

Hi!

I am assuming you assigned a value to 'Create a new folder' 'Folder path' input... if so, can you share which WDL expression, or value are you currently assigning?

 

If so, I believe 'Create a new folder' execution is currently failing, right?

Can you share a screenshot of your last flow execution, so we can see details of the error and also the Folder name you are trying to add?

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@efialttes This is the expression I used:

concat(outputs('Get_user_profile_(V2)')?['body/displayName'],outputs('Get_response_details')?['body/r5b183a83ba534d0e94fa4a61fabaef99'],outputs('Get_response_details')?['body/submitDate'])

 

and this is the error message:

微信截图_20200916165852.png

 

@efialttes I know what's the issue now, the time stamp that I'm trying to add into the folder name has "/" in it, after I delete the time stamp the flow works and folder created.

 

Now only one issue remain: store the attachments to the newly created SharePoint folder.

 

How can I do that? I already has an array variable that stores all the uploaded attachments, any idea which function I should use for this? Can you help me on it?

Hi!

I would use 'Apply to each' action block, assign as its input the attachments array.

THis blocks iterates all through your array elements and execute its internal logic N times (being N the nr of elements on your array)

 

Now inside 'Apply to each' I would add SP 'Create file' action block

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@efialttes I took your advice and built this:

微信截图_20200917091325.png

 

For the File name I use the expression: name(variables('varAttachment') ;

For the File content I use the expression: Content(variables('varAttachment')

 

I'm absolutely sure that my expression is wrong, and it returns error like this:

微信截图_20200917112948.png

 

 

BTW, this is how I define my variable for attachment:

微信截图_20200917091215.png

 

 

Can you help me with this?

Thank you!

Hi!

We are closer to a happy ending...

"...For the File name I use the expression: name(variables('varAttachment') ;

For the File content I use the expression: Content(variables('varAttachment')..."

 

Since you are inside an Apply to each iterating all through your attachments array whose elements are objects with two attributes ('Name' and 'Content'), I wuold use the following WDL expressions instead:

item()?['Name']

item()?['Content']

 

Hope this saves your day



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@efialttes 

Yes, just one more step,

 

I tried the following :

item(variables('varAttachment'))?['name'];

item(variables('varAttachment'))?['Content']

 

and

 

item()?['Name']

item()?['Content']

 

Both times the flow run successfully but no files added to folder, not sure what the issue is, maybe the expression again, I'm kind of newbie so I don't really know how to make expression...

Hi again!

"Both times the flow run successfully but no files added to folder"

So we are closer to a happy ending, right? I mean, in your first post Flow crashed. Now it succeed, even though its result is not the expected one.

 

Now, on your new problem: no files are added to the folder.

You are my eyes here. You know which changes you added to the last flow design you shared, and if needed, share a new screenshot from your flow design.

You can also inspect the flow execution and figure out how many times the first 'Apply to each' is executed, so this way we can figure out if the array is empty or not. And, you can figure out how many times the second 'Apply to each' (the one with the 'Create file' action block inside) is executed also. If not sure how to figure out it, you can also share a screenshot from your flow execution

 

THe more valuable feedback you can provide the faster you will get a good insight

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@Derek4 

Did you finally solve the issue?

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@efialttes 

Yes, I have solved the issue, in an old way...

 

I use the same method that I used to append to the attachment array variable:

 

First, get file content using path (OneDrive for business)

Second, create file (SharePoint)

Third, put the above in an Apply to each:

微信截图_20200922113244.png

 

and it worked... in this old way...

 

I think the issue with using the attachment array variable is the wrong folder path I type in with Create file in SharePoint, I insert an "forms" in the folder path...

 

Thank you!

View solution in original post

@efialttes 

 

I tried the following

item(variables('varAttachment'))?['Content']

item(variables('varAttachment'))?['Name']

 

it returns an error

微信截图_20200922115242.png

 

and this is how I built the flow:

微信截图_20200922115302.png

 

 

Thanx for sharing, @Derek4 !

Contributions like yours make this community great!

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (59,354)