cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Phineas
Community Champion
Community Champion

Power Apps V2 - Again

For those who have helped me in the past I beg your patience.

I am still struggling mightily to under how to make Power Apps V2 work for me.

I have a Power Apps with an attachment upload screen.

I am using Power Apps V2 for the first time, to upload attachments to an SP Library.

I managed to get bits and pieces of meta data to the library put I can't view attachment when I open.

Goal:
Use Power Apps V2 Create File to upload document, and an Update file (properties only) to append 'Client ID', 'Document Name', 'Attachment Comment' from the Power App screen to the attachment/item being uploaded.

SP Library -

Phineas_0-1696022997184.png

Power App Screen -

Phineas_1-1696023070597.png

 

Power App Submit Button Formula -

Phineas_2-1696023151219.png


My flow -

Phineas_4-1696023242933.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Most Valuable Professional
Most Valuable Professional

The error is because you have 5 string parameters and one file parameter but supply 4 text values and one file value.  you need to specify the same number of parameters as you define in the flow.

 

Part of the problem may be that you aren't saving and refreshing the flow in Power Apps between making changes.  The intellisense in Power Apps shows 4 text parameters when you've defined 5f and doesn't show the file parameter at all. Anytime you make a change to the flow you need to save it and then refresh it in Power Apps.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Pstork1
Most Valuable Professional
Most Valuable Professional

You are still using Document type for the file name when creating the file. You won't be able to open the file if it doesn't have a file extension that matches the contents of the file.  Your document name doesn't have an extension. Also your run line has 4 strings, but 5 text parameters are defined in the flow. I've already pointed out that the run() has to match the actual parameters you define. Yours don't



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

24 REPLIES 24
Pstork1
Most Valuable Professional
Most Valuable Professional

For the ContentBytes value in the File record you are sending do not use JSON() to process the image.  Just reference the file in the attachment control directly.  Here's an example from one of my apps. In this case I'm only sending the first file in the attachment control.

 

UploadFile.Run(First(AttachmentControl.Attachments).Name,
  {file: {name: First(AttachmentControl.Attachments).Name,
  contentBytes: First(AttachmentControl.Attachments).Value}})

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Thank you.

How do I write the other fields in to the formula?

Pstork1
Most Valuable Professional
Most Valuable Professional

The first parameter is just a string so Label15.Text will work for that.  Other than that what do you mean by the other fields in the formula?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Trying to get all this in but can't get the language correct.

Top of code window has -
Run(text, text_1, text_2, text_3, text_4) | text: Input

This is the code I'm trying -
UploadClientDriversLicenseDocumentsFlow.Run(
{text_1: Upload_Client_ID_Fld.Text,
text_2: Label15.Text,
text_3: TextInput1_3.Text,
text_4: Label1.Text,
{text: {name: First(Client_Attachments_Control_2.Attachments).Name,
contentBytes: First(Client_Attachments_Control_2.Attachments).Value}});

My flow -

Phineas_0-1696027807420.png

 



Pstork1
Most Valuable Professional
Most Valuable Professional

The parameters in the flow trigger need to match what you are submitting. You've got 5 string parameters, but your code is submitting 4 text parameters and a non-standard JSON record. The last parameter needs to be of type file and use the keyword file: not text: 

 

You can't send a JSON record other than specific types like {file:...} as a parameter.  



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

I am still unsure on the structure or how to interpret your clarification completely.

I've updated the formula to the following, and I am getting an error at the end. Say 'The formula contains CurlyClose where ParenClose is expected. 

UploadClientDriversLicenseDocumentsFlow.Run(
{Input: Upload_Client_ID_Fld.Text,
ClientID: Label15.Text,
AttachmentComments: TextInput1_3.Text,
ReprenstingDocument: Label1.Text,
file: First(Client_Attachments_Control_2.Attachments).Name,
contentBytes: First(Client_Attachments_Control_2.Attachments).Value}});

Phineas
Community Champion
Community Champion

I've been at this for three days, across three or four forum folks, and still can't get it.

I've watched this video 10 times. I can't figure out how to incorporate his work into mine.
          https://youtu.be/yDRzgl9JysU

He's sending an email; I'm trying to upload attachments. Not exactly the same, which makes it difficult for me to translate.

If you could help me with the 'actual' writing of the code - as much as I appreciate the guidance and words of wisdom, that would be great.

I've re-written my code a hundred times and haven't gotten it right.

Admittedly, I have some cognitive limitations, but I've come a long way.

Pstork1
Most Valuable Professional
Most Valuable Professional

The file parameter needs to be passed as a JSON record.  You are missing the opening { for the record. That's why you are getting the error.  Also the string parameters don't have keywords. They are identified by their position in the list. It should be

 

UploadClientDriversLicenseDocumentsFlow.Run(
Upload_Client_ID_Fld.Text,
Label15.Text,
TextInput1_3.Text,
Label1.Text,
{file: First(Client_Attachments_Control_2.Attachments).Name,
contentBytes: First(Client_Attachments_Control_2.Attachments).Value}});

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Pstork1
Most Valuable Professional
Most Valuable Professional

See my response above where I've added the missing brace { to your code.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Thank you, for your patience and assistance.

I placed the following in the submit button and got the following error -

     'Invalid argument type (Record). Expecting a Text value instead."

Phineas_0-1696045460742.png

 

Pstork1
Most Valuable Professional
Most Valuable Professional

Did you add a File type parameter as the fifth parameter like you had in the earliest screenshots? The error says you are trying to pass the file type parameter to a text parameter.  Can you provide a screenshot of the current trigger?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Are you meaning here, circled?

Phineas_1-1696086316838.png

 

Also, I am seeing that maybe I should have 'varBase64Only' in the SharePoint formula (shown below), and/or maybe in the flow (at the arrow shown above) in order to be able to view the documents.

Your thoughts?

UploadClientDriversLicenseDocumentsFlow.Run(
Upload_Client_ID_Fld.Text,
Label15.Text,
TextInput1_3.Text,
Label1.Text,
{file: First(Client_Attachments_Control_2.Attachments).Name,
contentBytes: First(Client_Attachments_Control_2.Attachments).Value}});

Pstork1
Most Valuable Professional
Most Valuable Professional

As I explained in an earlier reply you can't send the file content as a text string. You have to send it as a  file record. To do that the parameter needs to be created as a file parameter not a text parameter. What you have circled is a text parameter.

 

And no you don't need VarBase64 if you send the file as a file record you will have the right file contents to make it viewable. 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Yes, sir; Though, I still can't quite translate your instructions into what to actually do.

That said, I think I'm getting close.

My Library: I finally got all the content in the correct columns, when I test the flow manually from Power Automate -

Phineas_0-1696092764799.png

My Flow: When I test manually it delivered the above output to the Library.

Phineas_1-1696092922334.png


My Power App: This is where I'm running into some of the problems. I believe I've got the input order correct; However, I don't know how to finish it. What is the language for the record. This is where all that basetobinary use to go in the old Power App. 

Phineas_3-1696093476214.png

 

 

Pstork1
Most Valuable Professional
Most Valuable Professional

The final parameter is a record with a keyword of file: It contains a record that has two properties with the keywords of name: and contentBytes: Name: is a text property and contains the filename you want to use for the file in the flow. ContentBytes is the Value property pulled from one of the files in the attachment control on your screen. The attachment control can hold multiple files, So its a collection/array or files. If you only want to upload one file then you can get the value using first(NameOfAttachmentControl).Value. You can get the current name of the uploaeded file using first(NameOfAttachmentControl).Name. So to pass that as a file record it takes the following record format for the final parameter.

 

{file: {name: {first(attachmentControlname).name, contentBytes: first)attachmentControlname).value}}

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

Power Apps was fine with this - 

Phineas_1-1696099996484.png


Power Apps didn't like the addition. Also, it wouldn't take attachment language with the last text parameter; I got (Received 6; Expected 5) error.

Error:
'Invalid argument type (Record). Expecting a Text value instead'

Phineas_3-1696100497772.png


Should the 'FileName' have a default parameter and not one I add - such as 'DocumentType'?

Phineas_2-1696100330404.png

 

Pstork1
Most Valuable Professional
Most Valuable Professional

As I've said before you need to add a file parameter as the last parameter in the trigger. Your screenshot still shows 5 string parameters and no file parameter. That's why it doesn't like the file: record. there is no file parameter. The filename can be either passed seperately or as the Name: attribute of the file record.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Phineas
Community Champion
Community Champion

If I may, pleading through teary eyes and sniveling nose...can you show me what that would look like, please?

 

It ought to be obvious, by now, that I am not understanding this last part.

 

Thank you.

Pstork1
Most Valuable Professional
Most Valuable Professional

I'm not sure why you are using the Document Type parameter for the name. I assume that is a mistake.  But assuming you need the rest somewhere in the flow it would look like this

image.png

And the run command would be this

UploadClientDocuments.Run(
Upload_Client_ID_Fld.Text,
Label15.Text,
TextInput1_3.Text,
Label1.Text,
{file: First(Client_Attachments_Control_2.Attachments).Name,
contentBytes: First(Client_Attachments_Control_2.Attachments).Value}});


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (3,148)