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?

6 REPLIES 6
Rebetcha
MVP

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.

v-micsh-msft
Community Support
Community Support

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

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

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.

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

Anonymous
Not applicable

You helped me a lot! Thanks! 🙂 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Top Solution Authors
Top Kudoed Authors
Users online (3,389)