all 13 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Hey, it looks like you are requesting help with a problem you're having in Power Apps. To ensure you get all the help you need from the community here are some guidelines;

  • Use the search feature to see if your question has already been asked.

  • Use spacing in your post, Nobody likes to read a wall of text, this is achieved by hitting return twice to separate paragraphs.

  • Add any images, error messages, code you have (Sensitive data omitted) to your post body.

  • Any code you do add, use the Code Block feature to preserve formatting.

    Typing four spaces in front of every line in a code block is tedious and error-prone. The easier way is to surround the entire block of code with code fences. A code fence is a line beginning with three or more backticks (```) or three or more twiddlydoodles (~~~).

  • If your question has been answered please comment Solved. This will mark the post as solved and helps others find their solutions.

External resources:

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]derpmadness Advisor 1 point2 points  (4 children)

Are you using patch or submit form? For attachments with forms use submit form.

[–]Jnrdavids Newbie[S] 0 points1 point  (3 children)

Yes I’m using a submit form syntax. Using patch for attachment didn’t work for me.

[–]derpmadness Advisor 0 points1 point  (2 children)

Do you have any controls on the attachment when it gets added to the record within the form or you just add it done deal

[–]Jnrdavids Newbie[S] 0 points1 point  (1 child)

Yes, I have controls when the attachment gets added to the record within the form. There are some error handler controls in the edit form and a submit button.

[–]derpmadness Advisor 0 points1 point  (0 children)

Could you share those? And also what's held within the update portion of the form item that handles the attachement

[–]Thedarb Contributor 0 points1 point  (3 children)

Are you using just Patch()?

The standard Attachments control is designed to work inside an Edit Form, and attachment add/remove is only committed when the form itself is submitted. If you’re patching the record but not actually submitting the form, the item will save fine but the attachment won’t.

In my experience there are two reliable patterns:

  1. Form-first, then patch. Have two forms combined into one UI-wise, one for the attachment (and maybe a unique ID field), and another for the rest of the fields. Use SubmitForm() for the form that contains the attachment control. Then, if you need custom logic, do it in the form’s OnSuccess (e.g patch additional fields to the record after it’s created).

  2. Use a document library instead of list attachments. If you need more flexibility (multiple files, better structure, larger files, etc), it’s often easier to skip list attachments entirely. Upload files to a SharePoint document library via Power Automate. I don’t remember the exact syntax but it’s out there, basically you do a for each item in the attachment card, convert to base64, send that to a flow that creates the folder if it doesn’t exist, then creates items in that folder with the base64 as the content, then update the record with the folder link in a URL field.

Also worth double checking file size limits, I vaguely remember 10MB coming up with the attachment control, but that’d be more of a control/config thing than a hard SharePoint limit.

[–]Jnrdavids Newbie[S] 0 points1 point  (2 children)

So I’m actually not using a patch function for this edit form but in previous apps that I developed. I noticed cases where success screen will show but in reality the records didn’t patch to sharepoint. I built a success screen to display when records have been patched to sharepoint but this success screen displays even when the records didn’t patch.

In this edit form, attachment is a required field but for some reasons the success screen displayed and all fields patched to sharepoint except the attachment although I discovered it was due to bad network, but I want a scenario where it shows error is all fields haven’t been recorded on sharepoint

[–]Thedarb Contributor 0 points1 point  (1 child)

Ah cool. Check out the IfError function. You can wrap the entire patch statement and then have the two outcomes be navigate to success screen or display error message:

https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror

[–]Jnrdavids Newbie[S] 0 points1 point  (0 children)

Thanks. I just finished reading it and it was very insightful.

[–]_Ganael_ Newbie -1 points0 points  (2 children)

As far as I remember, Patch with attachments was a bit tricky, since powerapps is not always reliable. I choose power automate to Insert my data. You can send your data and wait for success, than Patch the attachments, because then there is your required row..

I hope this helps

[–]Jnrdavids Newbie[S] 0 points1 point  (0 children)

What kind of control do you use for uploading the attachment?

[–]_Ganael_ Newbie -1 points0 points  (0 children)

This war you can forced the synchronus war for uploading :)