cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Patch attachment to sharepoint

How can I allow the user to add attachments and submit it to a sharepoint list. This is my current patch statement for the data cards. SubmitForm(Form1);NewForm(Form1);Patch('CPQ Comment', Defaults('CPQ Comment'), {Title: DataCardValue3.Text, Comment: TextInput2.Text, Name_:Label6.Text, Date:Label7.Text}); Navigate(BrowseScreen1,Fade); Reset(TextInput2) 

powerapps890_0-1596648129940.png

I copied and pasted the attachment card from the edit form.

21 REPLIES 21
Highlighted
Super User III
Super User III

Re: Patch attachment to sharepoint

@powerapps890 

Attachments may not inserted using the PATCH function.

You must use SUBMITFORM to do it instead.  There are not any workarounds to do it inside of PATCH.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Highlighted
Post Prodigy
Post Prodigy

Re: Patch attachment to sharepoint

How do i submit the form to the data source using that then? @mdevaney 

Highlighted
Super User III
Super User III

Re: Patch attachment to sharepoint

@powerapps890 
The typical pattern is to insert a new row using PATCH and then SUBMITFORM.

// Insert new row in the datasource
Set(currentRecord,
    Patch(
        'CPQ Comment',
        Defaults('CPQ Comment'),
        {
            Title: DataCardValue3.Text,
            Comment: TextInput2.Text,
            Name_:Label6.Text, 
            Date:Label7.Text
        }
    )
);

// Submit the attachment in the form
SubmitForm(Form1);
NewForm(Form1);
Reset(TextInput2) 

 
Make sure you have this code inside the Item property of the Form.

currentRecord

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Post Prodigy
Post Prodigy

Re: Patch attachment to sharepoint

so that whole thing goes in the button? I don't understand how the attachment is being submitted because the new column I created in the data source is not being called. Also, it is saying currentrecord is not compatible with my data source. @mdevaney 

Highlighted
Super User III
Super User III

Re: Patch attachment to sharepoint

@powerapps890 
Yup, the whole thing goes in the button.  CurrentRecord must be from the same datasource as the Form or else an error will be raised.

Is the variable for PATCH at least returning a value?

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

Highlighted
Community Support
Community Support

Re: Patch attachment to sharepoint

Hi @powerapps890 :

In theory, using form control and submitform function is the only way to add attachments to existing records.

If you insist on using Patch function,you could consider take a try to only add the Attachments field within the form control.

I have made a test on my side:

1\Add an edit form(Form1)

DataSource

 

List3 /List3 is my data source/

 

DefaultMode

 

FormMode.New

 

2\Add a button 

OnSelect:

Patch(
    List3,
    Defaults(List3),
    {Title: 1},
    Form1.Updates
)

On your side, you should type following formula:

Patch(
        'CPQ Comment',
        Defaults('CPQ Comment'),
        {Title: DataCardValue3.Text, Comment: TextInput2.Text, Name_:Label6.Text, Date:Label7.Text}
, Form1.Updates )

Note: The Form1 represents the Edit form control within your app, which only display the Attachments field. 

I think these links will help you a lot:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Need-to-add-Attachment-to-a-PATCH-to-a-Share...

https://powerusers.microsoft.com/t5/Building-Power-Apps/Saving-attachments-using-Patch/td-p/277984

Best Rergards,

Bof

Highlighted
Post Prodigy
Post Prodigy

Re: Patch attachment to sharepoint

Currently I have editform1 which contains the attachment within detail form1. Can I do it this way? Maybe it does not need a patch function? I am just really not sure how to submit it to the sharepoint list with the other items without a button and patch. @v-bofeng-msft 

Highlighted
Post Prodigy
Post Prodigy

Re: Patch attachment to sharepoint

Where does the attachment go. Like if the column is called attachment where does that form go?

Highlighted
Community Support
Community Support

Re: Patch attachment to sharepoint

Hi @powerapps890 :

Sorry, I did not understand what you mean, could you describe it in detail?

Best Regards,

Bof

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,818)