cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Patch Function Assistance

Hi All,

 

I have followed the article presented by @ThatAPIGuy here: https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/Deep-Dive-Click-Through-PowerApps-Analy...

 

I am looking to utilize the Patch function to collect multiple dropdown selections.

 

For Example, a user makes dropdown selections

-John Smith

-Office Location

-Type

on ReviewScreen and reviews. Then needs to review an additional client and updates her dropdown selections accordingly.

-David Williams

-Office Location

-Type

 

How can I utilize the patch function to capture all of her selections and place each selection in the same column but on a new row of the excel workbook it's writing back to?

 

Current Patch Function:

Patch(ELAnalytics,Last(ELAnalytics),{ReviewType:ReviewTypeDD.Selected.Type},{ReviewOffice:OfficeDD.Selected.OfficeCode},{ReviewClient:ClientCB.Selected.ClientName})

This works great for capturing the 1st dropdown selections, but fails to capture any subsequent dropdown selections unless the user would close/reopen the app to create a new session. 

11 REPLIES 11
Highlighted
Super User
Super User

Re: Patch Function Assistance

If you want them to make a bunch of selections and then update the Excel all at once then you would want to save their selections to a collection. Then write your collection back to Excel. Collect(CollectionYouMade, Excel DataSource).

 

I kind of think of this like a PowerApps Shopping Cart.

 

Assuming I am understanding your question.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted
Resolver I
Resolver I

Re: Patch Function Assistance

Hi @Shanescows - Thanks for your reply.

 

I don't believe that is what I am looking for, here is a picture of my screen and the selections available:

 

ss1.PNG

 

When the user clicks create, it submits a flow. Then they can submit multiple times within the same session of using the app.

 

I am able to collect/patch all the initial dropdown selections but any second, third or fourth time they make selections it's not stored in the excel workbook which is what I'd like to achieve. 

So for instance just a new row created in the workbook if they create additional selections and it stores those in that row.

 

I want to use this data for analytical purposes based on the article mentioned in my initial post.

 

 

Highlighted
Super User
Super User

Re: Patch Function Assistance

What is the code on your Create button? 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted
Resolver I
Resolver I

Re: Patch Function Assistance

Patch(ELAnalytics,Last(ELAnalytics),{ReviewType:ReviewTypeDD.Selected.Type},{ReviewOffice:OfficeDD.Selected.OfficeCode},{ReviewClient:ClientCB.Selected.ClientName})

@Shanescows It has a bunch of bits in there but the part writing back to the excel workbook in onedrive for business is shown above.

 

The OnStart property of my app contains this:

Collect(ELAnalytics,{UserName:Office365Users.MyProfile().DisplayName,UserEmail:Office365Users.MyProfile().Mail,OfficeLocation:Office365Users.MyProfile().OfficeLocation,LoginDate:Today(),LoginTime:Text(Now(), "[$-en-US]hh:mm:ss" )})

 

Highlighted
Super User
Super User

Re: Patch Function Assistance

So to me that looks like you are just patching the last record in the data source. Is that what you want to do? I thought you wanted to create a new row which would be Patch(Datasource, Defaults(DataSource), {YourColumns.....})

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Resolver I
Resolver I

Re: Patch Function Assistance

@Shanescows Yes, so initially I set it up just as the article mentioned and collected the initial dropdown selections. Soon thereafter I realized that it was not collecting additional selections and that brings me to my dilemma. 

 

This is how I'm imagining it but based on your feedback it may not be possible.

 

I browse to the Review screen and make the selections, I move around the app, come back to the Review Screen and make additional selections, creates new row linked to the same session I had open just for the selections, but any screen views go to the first row that was created.

 

If that doesn't happen the issue then becomes it looks like the user has multiple sessions in the app which will skew the analytics if its not all tied together.

 

UsernameReviewScreenTypeOfficeClientDatePrintScreenSupportScreen_PowerAppsId_
EricCY1156John Smith5/7/2018  3414vdsdsv
  3156William Jones5/7/2018  3414vdsdsv
MichaelBY2142Keith Michaels5/7/2018  dsd213ds
Highlighted
Super User
Super User

Re: Patch Function Assistance

Eric - I have no doubt you can do exactly what you want to do. What I would recommend is you create a new app and use it to work out your logic in small pieces. Then apply it to this app with all of the moving pieces. You just need to break it down into the pieces of when you want to update the existing row and when you want to create new rows. You will probably need a primary and foreign key to tie the rows together. I promise you can do this whole thing. Just have to do baby steps to work out all of the logic. Logic is fun. 🙂 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted
Resolver I
Resolver I

Re: Patch Function Assistance

Thanks and I will see if I can figure it out.

 

Just to let you know, the formula you mentioned- Patch(Datasource, Defaults(DataSource), {YourColumns.....}) , does not work for creating a new row, it simply overwrites the existing row.

Highlighted
Super User
Super User

Re: Patch Function Assistance

@EricC This line 100% only creates a new row and would never edit an existing row.

 

IDProduct is the name of Excel Table

ID and Color are the names of my columns

 

Patch(IDProducts,Defaults(IDProducts),{ID: 11, Color: "Black"})

 

If you are getting different results then something else is messing with you. This is why I think you need to start smaller to work out this logic. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,144)