cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Advocate III
Advocate III

Collect Gallery Textfields

I created a form that has a gallery which contains three text fields. When the screen loads (onVisible) a collection using ClearCollect:

ClearCollect(CropsImpacted,{Filing:"",Mapfilename:"",Crops:""})

Then I added a gallery with the three text fields, and button:

gallery.jpg

 

I added to the OnSelect for the Add Button a Collect:

Collect(
    CropsImpacted,
    {
        Filing: filingInput.Text,
        Mapfilename: MapfilenameInput.Text,
        Crops: cropsInput.Text
    }
)

 

This adds a new row as desired, and an empty row to the collection, but doesn't collect any data from the Text Fields

fields.jpg

 

Collection for empty rows:

collection.jpg

 

I'm guessing I'm, missing for ForAll some where to iterate all text fields in each gallery row, and specify where each one goes in the collection, but I really don't know how to this. 

 

Thanks for any help.

 

7 REPLIES 7
Cooper01
Continued Contributor
Continued Contributor

You can update the collection in the OnChange of each text input. Example for the Filling textbox:

Patch(CropsImpacted, ThisItem, {Filing: Self.Text})
rubin_boer
Super User
Super User

hi @emfuentes27 , @Cooper01 gave a solution to you. for information, the reason why the collection is empty is when you collect a new item the texboxes are empty and the data is never updated (patched). 

 

Hope that shed some light on it.

@rubin_boer .Working on @Cooper01 solution now. By the way, the text fields are not empty. If you look at the images I provided when submitted the question, there some random text I entered. Thanks.

rubin_boer
Super User
Super User

@emfuentes27 when you look at your textbox in the gallery (at design time) what is the default value? It will be odd if the textboxes have those values as default and not be in the collection. 

 

enjoy the app.

emfuentes27
Advocate III
Advocate III

@rubin_boer . The initial values for the collection when the screen loads are just empty. Which is what want. Then when I fill text fields, and add them to the collection, which in return feeds the gallery. Thanks.

rubin_boer
Super User
Super User

sorry to label the point, i think we are talking pat each other. Laste attempt and i will let be, eeing you on your way to sort this which is great.

 

When you design the app, adding an item takes the default value of the textbox. when its empty it will add an empty item 

rubin_boer_0-1631736203814.png

 

adding items

At runtime, it will add empty boxes and you update them, these empty boxes are what was used to collect the data in your collection.

rubin_boer_1-1631736382925.png

The collection

rubin_boer_2-1631736420604.png

 

Now if your textbox would have had data in as default data, your collection would have captured it.

rubin_boer_3-1631736503704.png

 

Adding Items

At runtime

rubin_boer_4-1631736531995.png

 

you collection have the data now

rubin_boer_5-1631736564317.png

 

Hope this clears I more.

 

Have fun

 

 

 

 

 

 

 

 

Thanks again @rubin_boer . I noticed that behavior, and it was driving crazy. At the end I decided to just create three text field outside the gallery, and it works much better, and I think is easier to manipulate the data. I just deleted the first row of the collection after declaring it:

ClearCollect(CropsImpacted,{Filing:"",Mapfilename:"",Crops:""});
Remove(CropsImpacted,First(CropsImpacted));

 

I know this is probably a very ugly solution, but it's working as I wanted. If you have a better and cleaner solution I would appreciated. Thanks so much.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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