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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,683)