cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vsolanon
Helper III
Helper III

Saving attachment using Patch in a SP List

Hello Experts!

 

I have a PowerApp which have an Edit Form connected to a SharePoint list. Within the SP list, there is a field named 'Letter Status' which is a  dropdown with the option: Sent, Pending and 'To be sent. Once the ' Letter Status' is changed to "To be sent", a Flow will start and will send an email to a specific person (specified in the SP List) with the attachment included (for that specific item). 

 

When the user entered the application, he/she needs to select a person from a Gallery, once selected the information will be displayed on the EditForm. Then, the user will need to attach a document in the field Attachments and once a document is attached, a button named "Send Letter" will be visible. When the button is pressed, it will automatically update the 'Letter Status' of that specific item to "To be sent" using Patch and the flow will starts. (I want to update the column 'Letter Status automatically once the button is pressed, not manually by the user).

 

Currently, the information is being updated correctly, however, the attachment is not being saved in the SP List.

My main challenge is to know how I can save the attached document in the SP List via the Patch function. Please find below the formulas used.

I have tried including the  EditForm.Updates within the expression, but I got an error. 

 

Visible property of the button "Send Letter":

If((CountRows(DataCardAttachment.Attachments))<1,false,true)

 

OnSelect property of the button "Send Letter":

Patch(
          'Data Source',
           {ID: Gallery1.Selected.ID},
           {'Letter Status':{
                  '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value:"To be sent"}
          } 
)

 

 

Any suggestion is very much appreciated!! 🙂

11 REPLIES 11

Hi @vsolanon ,

 

I just made a further test and can reproduce your issue if 'STA Letter Status' field is also added in EditFrom.

Is that the same with your case?

 

If 'STA Letter Status' field is also added in EditFrom, The Patch function contains two 'STA Letter Status' field value, which causes a conflict. 

So please remove the 'STA Letter Status' Data Card in EditForm, the issue will fixed.

Hope this helps.

Sik

@v-siky-msft thank you so much!

I removed the field and it work like a charm:)

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,671)