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

Collect item depending on number in TextInput

Hi guys,

 

I have a gallery, in which I display different items. There is also a TextInput in the gallery. When I type in a number in the TextInput, I want to collect this item in a collection multiple times (based on the number in the textinput).

 

Can anybody help?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
PowerAddict
Level 10

Re: Collect item depending on number in TextInput

Try something like this:

On the OnVisible property of the screen or the OnStart property of the app, have a collection of numbers (until the max number a user can enter)

ClearCollect(NumberCollection,["1","2","3","4","5","6","7","8","9","10",...,"98","99","100",...])

Then on the OnSelect property of a button, have this to collect the item multiple times:

ForAll(FirstN(NumberCollection,Value(ThisItem.TextInput1.Text)), Collect(CollectionName, ThisItem))

You might have to access the text box in a slightly diff way than ThisItem.TextInput1.Text

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

View solution in original post

9 REPLIES 9
PowerAddict
Level 10

Re: Collect item depending on number in TextInput

When you say "collect this time" which item are you referring to? All items in the gallery or a specific item from the gallery?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
katunar
Level: Powered On

Re: Collect item depending on number in TextInput

Hi @PowerAddict,

 

Right now, when I type in a number in the textinput, the specific item will be collected.

 
 
PowerAddict
Level 10

Re: Collect item depending on number in TextInput

So if I understand you right, if the user types in 2 in the text box, you want to add the 2nd item in the gallery 2 times into the collection. Is that right?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
katunar
Level: Powered On

Re: Collect item depending on number in TextInput

In every record, there is a text box. So when the user types in a 3 in any of the text boxes, I want the item (which is located in the same record as the text box I just typed the 3 in) to be collected 3 times in a collection.

PowerAddict
Level 10

Re: Collect item depending on number in TextInput

Screenshot_20191114-015326_Samsung Notes.jpg

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

katunar
Level: Powered On

Re: Collect item depending on number in TextInput

Exactly, that's what I need!

PowerAddict
Level 10

Re: Collect item depending on number in TextInput

Try something like this:

On the OnVisible property of the screen or the OnStart property of the app, have a collection of numbers (until the max number a user can enter)

ClearCollect(NumberCollection,["1","2","3","4","5","6","7","8","9","10",...,"98","99","100",...])

Then on the OnSelect property of a button, have this to collect the item multiple times:

ForAll(FirstN(NumberCollection,Value(ThisItem.TextInput1.Text)), Collect(CollectionName, ThisItem))

You might have to access the text box in a slightly diff way than ThisItem.TextInput1.Text

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

View solution in original post

katunar
Level: Powered On

Re: Collect item depending on number in TextInput

Thank you very much, this works perfectly! Very smart way to implement a loop!

PowerAddict
Level 10

Re: Collect item depending on number in TextInput

Awesome! Glad I could help!

Good luck with the rest of your app!

Feel free to reach out in case of any questions!

Hardit (Haman)

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,846)