Hi all,
My first time posting on this great forum having been a lurker for some time.
There is an issue with a Power App that I have built that triggers a Power Automate flow. I’ll explain.
I have built a very basic form in PowerApps with 4 fields. One of these fields is an ‘Attach file’ control.
When a user clicks the Upload button a workflow is triggered that moves the submitted form and attachment to a designated SharePoint list. Depending on which area of the business they selected on the form (‘select area’ dropdown), is where the form entry will sit, fine so far.
I will add that there is also a hidden text field within a card in Power Apps that changes the name of the document to be uploaded to SharePoint, so all documents have a similar naming convention no matter what the name of the document is.
PowerApps name change code is shown below:
IfError(
Office365Users.UserProfileV2(DataCardValue2.Selected.Email).surname & ", " & Office365Users.UserProfileV2(DataCardValue2.Selected.Email).givenName & ", Employee Form " & If(
Month(Now()) > 6,
Year(Now()),
Year(Now()) - 1
) & Text(
Now(),
"-mm-dd - hh:mm:ss"
) & "." & Last(
Split(
First(FileAttachments.Attachments).Name,
"."
)
).Value,
""
)
Workflow:
This flow works fine except….
….when the flow is run, and the Power Apps form is loaded into its designated SharePoint list, on clicking the attached document within the list row, I receive this error.
Just for further information, here is one of the 10 cases from the 'Switch' (ive had to block some naming out due to confidentiality)
Help! I've spent hours searching for solutions for this error but have come across nothing so far that matches this exact issue. I can delve in a little more if required. Thanks so much.
Thank you very much Pstork for your time, very helpful. I have now solved this issue thanks to your help.
YOu only need the name parameter if you want to change the name of the file during uploading. The filename with extension part is a string that is a simple filename with the file extension. Something like, "document1.docx". You can get it from the name value of the file in the attachment control. The contentBytes property is the Value property of the file from the attachment control. The file name of the file created by the flow is controlled by what you put in the filename property of the Create File action. You can use the name property of the file: record you upload or some other string you submit as a parameter. In the screenshot above that would be the name parameter. Either way it has to be a valid filename with a file extension like .docx or .pdf. Otherwise the file won't open.
Thanks again for your help Pstork. A couple of questions as I am fairly new to power apps and automate, apologies.
What would I expect to use this part of the code for the 'filename with extension' please? I keep getting 'Run has invalid arguments'. I've experimented with the text from the 'fullfilename.Text' which holds the name change text for the attachment, but to no avail!
fullfilename.Text,
{file: {name: <<filename with extension>>, contentBytes: First(FileAttachments.Attachments).Value}
Am I correct in thinking that I have to add the contentBytes and name parameters to the Power Apps V2 as shown below, before I make any changes to the App code? Eg.
Or am I miles out here!
Thanks so much Pstork, my head is hurting! 😆
The spot where you reference the attachment control value is where you need to define a file parameter and send that file as a file record.
uploadflow.Run(
DataCardValue2.Selected.Email,
DataCardValue3.Selected.Email,
DataCardValue4.Selected.Value,
fullfilename.Text,
{file: {name: <<filename with extension>>, contentBytes: First(FileAttachments.Attachments).Value}}
);
Thank you very much for your response Pstork. Interesting, specifically adding Power Apps V2 as the trigger in the flow and the parameter.
This is the code for the 'Upload' trigger button btw if that helps for more info, ref: the run in Power Apps.
uploadflow.Run(
DataCardValue2.Selected.Email,
DataCardValue3.Selected.Email,
DataCardValue4.Selected.Value,
fullfilename.Text,
First(FileAttachments.Attachments).Value
);
ResetForm(frmUpload);
UpdateContext({VarConfirm: true})
So I include the parameter within the app Power Fx code I presume instead of Uploadflow.run?
Thanks a lot!
1) Remove the Power Apps trigger and use the Power Apps V2 trigger instead. Then instead of createing the parameters using Ask_in_PowerApps you can create them directly in the trigger.
2) For the file create a File type parameter as the last parameter in the list.
3) include the file parameter as a {file: } record with two keywords Name: and ContentBytes:
Call your flow using something like this as the run line.
UploadFile.Run(NewFileName,
{file: {name: First(AttachmentControl.Attachments).Name,
contentBytes: First(AttachmentControl.Attachments).Value}})
When you create the document in the flow use the NewFileName parameter and the contentBytes parameter.
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional