cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Akhilesh_Thota
Regular Visitor

Additional Rows getting added in gallery grid

Hello,

I'm making a canvas powerapp with a grid that can be edited using SharePoint list as a database. I've included buttons to add, delete, and duplicate existing rows in the grid; all other options, except creating new rows, are functioning correctly. When I click Create New Item, it creates one row at the top and seven empty rows at the bottom of the list. Because my grid contains validations, the data is not stored until I delete the seven empty rows at the bottom of the grid. Please take a look at the screenshots below. Could someone please help me in resolving this? @RandyHayes@WarrenBelz or @AmDev can one of you please help? tagging as you are the top kudoed members last month.

Screenshot 1: when clicked on new item 1 row getting added at the top which is expected.

Akhilesh_Thota_0-1640067027785.png

Screenshot 2: 7 additional rows getting added at the end of the grid which creating problem. Everytime i click on new item, it is creating a row on top and 7 additional rows at the end of the list.

Akhilesh_Thota_1-1640067115357.png

Screengrab 3: function which i have currently added for new item creation.

Akhilesh_Thota_2-1640067558100.png

 

Please let me know if any further information is required.

Thanks,
Akhilesh

 

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @Akhilesh_Thota ,

Why are you using Patch and what is varNewRecord

Set(
   varNumber, 
   varNumber + 1
)
Collect(
   colGridData,
   {ID: varNumber}
);

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz,

 

To avoid the app querying the data source every time to acquire the schema, a new variable was established on the app OnStart function and set the variable number as shown below.

Akhilesh_Thota_0-1640171070853.png

 

When we check the variable, it creates an empty column temporarily, but the ID is blank because it has not yet been placed in the database, and a unique ID is required for the Sharepoint list, so we are patching the varNewRecord. I'm new to PowerApps and am still learning. I built the app by following the same steps outlined in the video below; if my explanation is not clear, can I please request you to watch the video from 20.00 minutes to 25.00 minutes to see exactly what I did.
https://www.youtube.com/watch?v=wI6SHGQ9ATg

Please help!

 

Thanks,
Akhilesh

Hi @Akhilesh_Thota ,

If you want to create a Variable from the Record

 

Set(
   varNumber, 
   varNumber + 1
)
Collect(
   colGridData,
   {ID: varNumber}
);
Set(
   varCurrentRecord,
   Last(colGridData)
)

 

but your question was around creating extra records and I supplied the collect code that will create only one.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz ,

 

Sorry if was not clear earlier, I was giving explanation for your question in the first comment where you asked why I am using a patch function and what is varNewRecord.

Akhilesh_Thota_0-1640178280452.png

 

 

I have updated the above collect code you have provided but the same problem is happening. When i click on the New Item button, it creates only one record at the top as expected but the additional records at the end of the gallery are also still being created. I have attached a GIF showing the bug, please see the attachment.

Hi @Akhilesh_Thota ,

There is something else going on here as the code

Collect(
   colGridData,
   {ID: varNumber}
);

could not possibly produce more than one record. It is the most basic of Collect commands adding one field to a new record in the collection. Have you tried running a Monitor session to see what is being triggered?

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

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 (2,698)