cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Responsive Resident
Responsive Resident

Patch() against Excel workbook returns error

I am finishing up my self contained Test Drive version of our company's PowerApp, so i have to keep all data local.

 

So far i'm having no trouble with Collect(), but in some cases, I'd like to explore persisting data in Excel.

 

however, when i use code like this:

 

UpdateContext({row: First(Filter(Data, Datum="SafetyTeam"))});
Patch(
 Data,
 row,
 {Value: row.Value + 1}
)

 

I get an errors like this:

 

"The first argument of 'Patch' should be a collection" (No, according to the docs, it should be a Data Source)

"The type of this argument 'Value' does not match the expected value of 'Hyperlink.'" Found type 'Number'. (really, well this code does not report that last error (SafetyIndex here is, indeed, a collection)

 

UpdateContext({rec: First(Filter(SafetyIndex, Label = "Member"))});
Patch(
 SafetyIndex,
 rec,
 {Weight: rec.Weight +1}
);

)

 

 

rookie error (again)?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Patch() against Excel workbook returns error

Hi Mcorning,

 

I have some updates for you.


Currently, Excel Static connection is read only. We are not able to write new data to it.
Please see this thread about “Patch function not working with local data source” for a reference:
https://powerusers.microsoft.com/t5/PowerApps-Forum/Patch-function-not-working-with-local-data-sourc...

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Re: Patch() against Excel workbook returns error

Hi Mcorning,

 

My understanding is that you want to save data to Excel table by using Patch function.

 

So I tried your code on my side, it worked and data can be saved to my Excel table.


My table is saved on Dropbox, and I configured the code looks like below. When I click the button to save data, it worked as expected.The code I am using is:

Patch(Student,First(Filter(Student,Name="aaa")),{RA2:First(Filter(Student,Name="aaa")).RA1+1})

OR

UpdateContext({test:First(Filter(Student,Name="ddd"))});Patch(Student,test,{RA2:test.RA1+1})

 

 If possible, please provide more details of your scenario.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Responsive Resident
Responsive Resident

Re: Patch() against Excel workbook returns error

Ah, there's the difference: you use Dropbox to access your workbook, i used "Add static data to your app" option in Add Data Source.

 

I am building a Test Drive version of our app for AppSource, so i cannot take any external dependencies.

 

So please repro using the same Data Source that i am.

Highlighted
Community Support
Community Support

Re: Patch() against Excel workbook returns error

Hi Mcorning,

 

Thanks for correcting me.


I tried the option “Add static data to your app”, create a connection to the Excel table saved on local.
Then when I used Patch or Update function with the similar code, I got the same error message with you, “The first argument of ‘Patch’ should be a collection”.
I haven’t found any related documentations on “Import from Excel”.
I am trying to collect this from my side and I will back to you once I got a response.


Thank you for your feedback and understanding.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Responsive Resident
Responsive Resident

Re: Patch() against Excel workbook returns error

roger. thanks a 0xF4240. eager for news. lives depend on this working...

Highlighted
Community Support
Community Support

Re: Patch() against Excel workbook returns error

Hi Mcorning,

 

I have some updates for you.


Currently, Excel Static connection is read only. We are not able to write new data to it.
Please see this thread about “Patch function not working with local data source” for a reference:
https://powerusers.microsoft.com/t5/PowerApps-Forum/Patch-function-not-working-with-local-data-sourc...

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

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

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,906)