cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to dynamically set "Item" property in "form" control

I would like to set dynamically the item to be edited in a "form" control.

 

Usually the "item" property is set to "Gallery.Selected". 

 

Do I now need to change the gallery.selected data? Or can I directy set the value of the "Item" property?

 

Can I set "gallery.selected" or the "item" property by the "on select" event? If so, how?

5 REPLIES 5
Rebetcha
Level 10

Re: How to dynamically set "Item" property in "form" control

In the item property there should be a reference to a record. What you could do is use a collection in which you store the item that you want to use on the form and reference that record in the 'item'-property. You need to add a clearcollect function to create the record in the collection to every part of the app from where you want to navigate to the 'form'-control. Of course the order of the function should be: first the clearcollect and second the navigate.

Community Support Team
Community Support Team

Re: How to dynamically set "Item" property in "form" control

Hi @Anonymous,

 

It is recommended to take a look at the following article first:

Understand data forms in Microsoft PowerApps

 

To have the Form control work property, we need to configure the DataSource property and the item property.

Item property is one single record from the table configured under DataSource property.

By default, the DataSource is not allowed to change once configured, but for the item property, we could take use of filter functions to find the proper record,

For example (using Display form as an example):

We have the following table as data source:

96.PNG

1. Data Source configured to 

'[dbo].[Product]'

2. Add a button, OnSelect property configured to: 

UpdateContext({ProductID1:If(ProductID1>5,ProductID1-4,ProductID1+1)})

3. Item property configured to : 

LookUp('[dbo].[Product]',ProductID=ProductID1)

 

When click the button, the item would change to the corresponding record:

97.PNG

 

EditForm is only available to configure the item property with Edit Mode, for more details, please check:

Edit form and Display form controls in PowerApps

 

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: How to dynamically set "Item" property in "form" control

Thank you for this hint.

 

I have implemented this and it worked well.

 

I did the following:

- created 4 screens (newPage1, newPage2, editPage1, editPage2)

- Item property in NewForm1 and NewForm2 is empty

- On the submit button I do the following (this is probably the complicated part):

 Patch(PowerAppsMultiPageDemo,Defaults(PowerAppsMultiPageDemo),{Title: DataCardValue9_1.Text,Feld1: DataCardValue10_1.Text},NewForm2.Updates);Navigate(BrowseScreen1,Cover)

 

For the edit Pages it was slightly easier:

- Item Property of EditForm1 and EditForm2 is set to "Gallery.Selected"

- On submit I do the following:

 Patch(PowerAppsMultiPageDemo,BrowseGallery1.Selected,EditForm1.Updates,EditForm1_1.Updates);Navigate(BrowseScreen1,Cover)

 

 

 

The only downside of it is that such an architecture is quite effortful. especially when it comes to changes, one always has to consider dependencies to the rules.

 

 

Anonymous
Not applicable

Re: How to dynamically set "Item" property in "form" control

Thankts for the second hint.

 

I'm curious to see if this leads to an even simpler approach.

 

I didn't know that I can filter the item property like this.

OrangeJuiceCup
Level: Powered On

Re: How to dynamically set "Item" property in "form" control

Thank you very much, Michael ()! That was just what I needed.

Helpful resources

Announcements
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: 82 members 4,507 guests
Please welcome our newest community members: