cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mcorning
Level 8

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
Community Support Team
Community Support Team

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
Community Support Team
Community Support Team

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.
mcorning
Level 8

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.

Community Support Team
Community Support Team

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.
mcorning
Level 8

Re: Patch() against Excel workbook returns error

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

Community Support Team
Community Support Team

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 407 members 2,732 guests
Please welcome our newest community members: