cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mattcole19
Level: Powered On

Data not saving to custom entity upon closing app

Hi,

 

I've created a canvas app that connects to an environment with two custom entities: Customer and ProcessStep.  For some reason data is not being saved to ProcessStep.  Everything works as expected when I keep the app open, but whenever I close and reopen the app, all the data in ProcessStep is lost!

 

My app dynamically adds records to ProcessStep on the click of a button.  There is a separate screen with a gallery that shows all the records in ProcessStep.  When I keep the app open, everything works as expected.  However, if I close and reopen the app, the gallery shows no data.  It seems that data is not being saved to the ProcessStep entity?  I'm not sure why this would be, as the Customer entity has a very similar design and stores everything as intended.

 

I'm fairly new to using Powerapps so please let me know if you need me to go into more detail on the issue. 

 

Thanks,

 

Matt

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Data not saving to custom entity upon closing app

Hi @mattcole19 

The Collect function is adding the object you have defined to a local collection called "ProcessSteps". In order to write the data back to the CDS you can either make use of the Update/UpdateIf function or the Patch function. 

Update/UpdateIf: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

Patch function: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

Hope that helps!

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


View solution in original post

5 REPLIES 5
Highlighted
Super User
Super User

Re: Data not saving to custom entity upon closing app

Hi @mattcole19 

Can you please share the formula/method you are using on your button click to create the ProcessStep records in your custom entity?

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


mattcole19
Level: Powered On

Re: Data not saving to custom entity upon closing app

/* Record Lead Info */
Collect(ProcessSteps, {Company: EditForm1.LastSubmit.Name, Step: "Record Lead Info", Status: "Complete", Employee: User().FullName, DateCompleted: Now() });

 

 

Now that I look at this, I assume the problem has to deal with the "Collect" function.  What function should I be using?

Super User
Super User

Re: Data not saving to custom entity upon closing app

Hi @mattcole19 

The Collect function is adding the object you have defined to a local collection called "ProcessSteps". In order to write the data back to the CDS you can either make use of the Update/UpdateIf function or the Patch function. 

Update/UpdateIf: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

Patch function: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

Hope that helps!

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


View solution in original post

mattcole19
Level: Powered On

Re: Data not saving to custom entity upon closing app

That should work, thanks!

 

Just out of curiousity, why is there no function to directly add records?  The "Patch" function seems to be a strange work-around method of adding rows to an entiity.  I imagine adding records is quite common among developers, so why not have a function to make this process simpler/clearer?

Super User
Super User

Re: Data not saving to custom entity upon closing app

Hi @mattcole19 

If you make use of the Form control, each of the fields are bound to fields in your datasource. There is a Submit command that you can call against the Form control which will then post the new record to CDS. Often I'll be adding data from multiple locations or unbound controls so I tend to favour the Update/Patch functions as they provide more flexibility.

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-form-detail

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 289 members 5,775 guests
Please welcome our newest community members: