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

After a Patch Save - How do you Populate Controls with the Record?

I have used a Patch command to save my data, but am wondering what the best way is to load the data from the record into the controls on screen. I used a collection, but unsure if this is the easiest way.

 

Thanks

7 REPLIES 7
Super User
Super User

Re: After a Patch Save - How do you Populate Controls with the Record?

Hi @sienna28 

 

After you patch a record, you can retrieve the information (ID) of the item patched 

 

example : 

Set(patchInfo, Patch(......)

 

patchInfo will contain the information you need (you can get the item id)

then perform a lookup function to get the item data

 

example lookup(datasource, ID = patchInfo.ID)

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

Community Support Team
Community Support Team

Re: After a Patch Save - How do you Populate Controls with the Record?

Hi @sienna28 ,

Do you want to reference the values from the record submitted using Patch function, then populate the controls in your app?

 

Based on the issue that you mentioned, I think a global variable could achieve your needs. You could consider save your Patch formula result into a variable, then you could use the record value through the gloal variable.

 

Please set the OnSelect property of the "Submit" button to following:

Set(
      SubmittedRecord,
      Patch(                           /* <-- Type your Patch formula here */
                'DataSource',
                ..
                ..
      )
)

Then you could reference the values from the SubmittedRecord variable into your controls:

SubmittedRecord.Column1
SubmittedRecord.Column2

...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sienna28
Level: Powered On

Re: After a Patch Save - How do you Populate Controls with the Record?

What I am asking is if I have saved data using Patch and then leave the screen and try to load the data from the SharePoint list, how should I do it.  It's easy using Forms, but unsure how to pull back data into controls otherwise.

Community Support Team
Community Support Team

Re: After a Patch Save - How do you Populate Controls with the Record?

Hi @sienna28 ,

Do you want to load the submitted record within your Edit form after you submit your form?

 

Based on the needs that you mentioned,  I think the solution I provided above could achieve your needs. You could consider use a global variable to store the sumitted record:

Set(
      SubmittedRecord,
      Patch(                           /* <-- Type your Patch formula here */
                'DataSource',
                ..
                ..
      )
)

Then you could use following formula to reference the column values from the previous submitted record:

 

SubmittedRecord.Column1
SubmittedRecord.Column2

...

 

If you want to populate the data into controls, please take a try with the following workaround:

Set the Default property of Text Input box to following:

 

SubmittedRecord.TextColumn1

Set the DefaultDate proeprty of a DatePicker control to following:

 

 

SubmittedRecord.DateColumn1

...

 

 

In addition, if you use a Edit form to collect your data entries, and you want to populate the Edit form with submitted record, please consider set the Item proeprty of the Edit form to following:

 

If(
    !IsBlank(SubmittedRecord),
    SubmittedRecord
)

 

or

If(
    !IsBlank(SubmittedRecord),
    LookUp('YourSPList', ID = SubmittedRecord.ID)
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sienna28
Level: Powered On

Re: After a Patch Save - How do you Populate Controls with the Record?

That's not really what I am looking for.

 

If I log off and then come back to the app another day, I want to load the record from the SharePoint list.

 

So..I have a list of records in a gallery - I pick one and I need to grab it and display on screen.

I am not using forms for this...just controls added manually to a screen.

 

If I don't read it into a collection and then populate controls, what is a simpler way to do it?

 

Thanks

Community Support Team
Community Support Team

Re: After a Patch Save - How do you Populate Controls with the Record?

HI @sienna28 ,

Based on the needs that you mentioned, I think the Last() function may achieve your needs.

 

The Last() function is used to retrieve the latest record from your data source. On your side, if you want to populate controls in your app, you could take a try with the following formula:

Set the Default property of the Text Input box to following:

Last('YourSPList').Column1

Set the DefaultDate property of the DatePicker control to following:

Last('YourSPList').DateColumn1

...

 

In addition, you could also consider save your submitted record as cacahed data into local device, then when you open your app another day, auto-load data from the cached data into your app.

Set the OnSelect property of the "Submit" button to following:

ClearCollect(
                    SubmittedRecord,
                     Patch(...)
);
SaveData(SubmittedRecord, "LocalData")

Set the OnStart property of the App to following:

LoadData(SubmittedRecord, "LocalData", true)

Then you could populate your controls using the following formula (e.g. set the Default proeprty of the Text Input box to following):

First(SubmittedRecord).Column1

or

LookUp('YourSPList', ID = First(SubmittedRecord).ID).Column1

NoteYou can't use the SaveData and LoadData functions inside a browser, either when authoring the app in PowerApps Studio or when running the app in the web player. To test your app, run it in PowerApps Mobile on an iPhone or Android device.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sienna28
Level: Powered On

Re: After a Patch Save - How do you Populate Controls with the Record?

Thanks - this particular app is working on a laptop.

Currently I am using collections - In most cases I won't be looking for the last record.

It could be any record I want to pull up  - so if I have a list of records in say a Gallery - when I select one I would like to pull out the details from the SharePoint list and display the record in the text boxes etc on screen. 

 

As you say though, perhaps a collection is the only way of doing this...

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 366 members 4,976 guests
Please welcome our newest community members: