cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GabrielGondin
Frequent Visitor

Problems when inserting attachments into the sharepoint list

Hello everyone,
I am developing an app similar to a shopping cart, the user can add multiple orders and send them, but an attachment is required for each order.
I am using a collection and the function for All and patch to send to the SharePoint list, after some research, I was informed that there is no possibility to send attachment with the patch function, only with Submit and then perform the edition of the SharePoint list with my other values using the Last Submit, so it was done, I created a form only with the attachment and another with the other fields, however, without success, there is some error in my code? is there another possibility to do this in power apps or even with power automate?

Translated with www.DeepL.com/Translator (free version)image.pngimage.png

1 ACCEPTED SOLUTION

Accepted Solutions

Hello, thanks for the help, I believe that this solution would only serve for a specific line, in my case I have a collection with several lines, but I managed to solve my problem!

I created two forms, one for the attachment and another for the other fields, in the attachment form I added another generic field as a key and left it invisible with a default value of two other columns together ( you can decide any value ), and sent this key field also to the gallery, when filling the fields and inserting it in the shopping cart is like this :

SubmitForm(FormAttachment); <---- send the attachment to the SP list in the attachment form ( will be sent the attachment and the key created)

Collect(  <-----Sending the form values ( with the other values ) to the collection 
    colpessoa,
    {
        
        
        ChaveCol: DataCardValue6.Text & DataCardValue9.Text,    <--- Column key 
        NomeCol: DataCardValue6.Text,
        SobrenomeCol: DataCardValue7.Text,
        IdadeCol: DataCardValue8.Text,
        CidadeCol: DataCardValue9.Text
        
        
        
    }
);

this way the attachment is sent to the SP list and the other fields are blank.
Then I used For All with Patch comparing the key column of the collection with the key column of the SP list , it looks like this :

ForAll(
    colpessoa,
    Patch( AuxiliarTesteMulti, LookUp( AuxiliarTesteMulti, Collumn key SP List  = Collumn key collection   ) , 
        {
            Nome: NomeCol,
            Sobrenome: SobrenomeCol,
            Idade: IdadeCol,
            Cidade: CidadeCol 
        } 
        
    )
);

this way I solved my problem, any questions I am at your disposal! Thank you all.

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @GabrielGondin ,

 

Do you want to add a attachment to a SP list item using Patch function directly?

 

If so, there is a an alternative solution, you could consider take a try to only add the Attachments field within the Edit form. I have made a test on my side, please take a try with the following workaround:

1\Add an edit form(Form3)

2\Add a button 

OnSelect:


Patch(
'List A',/*'List A' is my data source*/
First('List A'),/*Modify the first record in the data source*/
{Title: "1"},
Form3.Updates
)

 

vbofengmsft_1-1660705548901.gif

 

 

On your side, you should type following formula:


Patch(
'YourSPList',
'Your specified record',
{
Column1:TextInput1.Text,
Column2:TextInput2.Text,
Column3:TextInput3.Text,
...,
ColumnN:TextInputN.Text
},
EditForm1.Updates
)

 

Note: The Editform1 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

Hello, thanks for the help, I believe that this solution would only serve for a specific line, in my case I have a collection with several lines, but I managed to solve my problem!

I created two forms, one for the attachment and another for the other fields, in the attachment form I added another generic field as a key and left it invisible with a default value of two other columns together ( you can decide any value ), and sent this key field also to the gallery, when filling the fields and inserting it in the shopping cart is like this :

SubmitForm(FormAttachment); <---- send the attachment to the SP list in the attachment form ( will be sent the attachment and the key created)

Collect(  <-----Sending the form values ( with the other values ) to the collection 
    colpessoa,
    {
        
        
        ChaveCol: DataCardValue6.Text & DataCardValue9.Text,    <--- Column key 
        NomeCol: DataCardValue6.Text,
        SobrenomeCol: DataCardValue7.Text,
        IdadeCol: DataCardValue8.Text,
        CidadeCol: DataCardValue9.Text
        
        
        
    }
);

this way the attachment is sent to the SP list and the other fields are blank.
Then I used For All with Patch comparing the key column of the collection with the key column of the SP list , it looks like this :

ForAll(
    colpessoa,
    Patch( AuxiliarTesteMulti, LookUp( AuxiliarTesteMulti, Collumn key SP List  = Collumn key collection   ) , 
        {
            Nome: NomeCol,
            Sobrenome: SobrenomeCol,
            Idade: IdadeCol,
            Cidade: CidadeCol 
        } 
        
    )
);

this way I solved my problem, any questions I am at your disposal! Thank you all.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,061)