cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Skilled Sharer
Skilled Sharer

What is the best way to allow users to edit records in a collection?

The Question

What is the best way to allow users to edit records in a collection?


The Setup

Survey-takers are gathering data door-to-door (to help address COVID-19 related needs) and may sometimes need to work offline.

 

The Functionality

I am trying to allow my users to edit records in a collection before they upload their data. It needs to be a collection as they may not have internet where they happen to be, so may not have access to the SP list where the data is being populated.

 

The Structure

Populate a gallery with the collection. Use the boilerplate arrow in the gallery card to navigate to a page with EditForm on it. The "boilerplate arrow" on the card in the gallery has this code: 

 

 

Navigate(HISEdit,ScreenTransition.Cover, {SelectedItem: HISGallery.Selected})

 

 

...and is drawing from this data source: 

colCovidTeamSavedItems

 

The EditForm has this in the DataSource property:

colCovidTeamSavedItems

 

The Problem

It seems that I cannot use a collection as a data source in EditForm.

 

The Question (again)

What is the best way to allow users to edit records in a collection?

1 ACCEPTED SOLUTION

Accepted Solutions
JR-BejeweledOne
Super User
Super User

First you will need to delete the form and replace it with the necessary fields.    Change your OnSelect in your gallery to Set(varRecord, ThisItem).

 

Now you can use varRecord in the Default property of your control.

 

Here is an example from my Holiday app.  varRecord contains all the data from the selected gallery item in a record format that you can use in your default properties.

 

varRecord.png

In this case I could set my Country dropdown's default property to varRecord.Country

 

What I do is set a context variable to true when the Edit pencil is clicked.   Then in my save formula I can use that to trigger an Update (you must update all the fields in the record), UpdateIf(requires a formula to evaluate, and only updates the fields you specify) or a patch.

 

Example:  UpdateContext({ EditItem: true })

 

If(EditItem,

   UpdateIf(xxxxxxx

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

1 REPLY 1
JR-BejeweledOne
Super User
Super User

First you will need to delete the form and replace it with the necessary fields.    Change your OnSelect in your gallery to Set(varRecord, ThisItem).

 

Now you can use varRecord in the Default property of your control.

 

Here is an example from my Holiday app.  varRecord contains all the data from the selected gallery item in a record format that you can use in your default properties.

 

varRecord.png

In this case I could set my Country dropdown's default property to varRecord.Country

 

What I do is set a context variable to true when the Edit pencil is clicked.   Then in my save formula I can use that to trigger an Update (you must update all the fields in the record), UpdateIf(requires a formula to evaluate, and only updates the fields you specify) or a patch.

 

Example:  UpdateContext({ EditItem: true })

 

If(EditItem,

   UpdateIf(xxxxxxx

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,940)