cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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?

6 REPLIES 6
Highlighted

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.

Highlighted
Community Support
Community Support

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.
Highlighted
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.

 

 

Highlighted
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.

Advocate I
Advocate I

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

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

Highlighted
New Member

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

You helped me a lot! Thanks! 🙂 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,729)