cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vloecken
New Member

Datatable fill by pressing Button

Hi,

 

I want to fill a Datatable in a loop by pressing a Button.

 

For example by pressing the Button the existing Datatable will be written as like :

 

SerialNr.               PersNr.

1                            2345

2                            2345

3                            2345

4                            2345

5                            2345

6                            2345

7                            2345

8                            2345

9                            2345

 

Does somebody has a Idea how to do it ?

 

Regards

 

Vinzenz

3 REPLIES 3
EricRegnier
Super User
Super User

Hi @vloecken 

If you're using model-driven apps, then this is out of the box (OOB). All you need to do is define your table and form and use the OOB "New" button as the button to create new rows.

To create a table: https://docs.microsoft.com/powerapps/maker/data-platform/create-edit-entities-portal 

To set up auto number (SerialNr. column): https://docs.microsoft.com/powerapps/maker/data-platform/autonumber-fields#create-an-autonumber-colu... 

To create a form: https://docs.microsoft.com/powerapps/maker/model-driven-apps/use-main-form-and-components 

Hope this helps!

Rivius
Resolver III
Resolver III

Using a combination of ForAll, Sequence, and Patch to a collection that the table is connected to might do it.  You can define how many rows you want in Sequence then in the Patch function SerialNr would be whatever Sequence you're on and PersNr. would be what you have there already.

Rivius_0-1617030712607.png

Code for the 'Generate' button:

ClearCollect(
colDataTableCollection,
Blank()
);
ForAll(
Sequence(9) As myLoop,
Collect(
colDataTableCollection,
{
SerialNr: myLoop.Value,
PersNr: Value("2345")
}
)
);
Rivius
Resolver III
Resolver III

Just edited my code there so it doesn't create a blank line like in the screenshot.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (1,730)