web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add a new gallery row ...
Power Apps
Answered

Add a new gallery row with ID and CreateDate auto set?

(0) ShareShare
ReportReport
Posted on by 437 Super User 2024 Season 1

I have a gallery:

PassType (Daily, month, etc...)

PassFee (a $ value)

PassId (unique Id of the record)

CreateDate (date/time stamp of the record creation)

There are other fields but they're irrelevant to the example

 

How do I add a new row to my Gallery with PassId to 'Max(colPassesUpdates,PassId)+'1 and the CreateDate to Text(Now(),"mm/dd/yyyy hh:mm:ss")', and then pass that to my collection?

Categories:
I have the same question (0)
  • Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    OK, I figured part of this out.  I can add a new row to the Gallery and Collection using:

    Patch(colPassesUpdates,Defaults(colPassesUpdates),PassType:"",Duration:"",Notes:"",Active:true,PassId:Max(colPassesUpdates,PassId)+1,CreateDate:Now()})

     

    However, when I try to Patch that back to SQL I get a Network Error: "network error using patch function the specified record was not found"

  • Verified answer
    Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    Update in case this helps anyone (I figured this all out):

     

    Problem:

    What I was trying to do was allow users to create and fill-out multiple new records in my gallery. In other words, add a row, add another row, add another row.  Fill out all three rows at the same time and then Patch them to my SQL database.  The problem though was that without a unique ID in the collection, the gallery thought all three rows were the same.  So I would populate the first field in row1 and that text would then appear in the first field of rows 2 and 3 when I tabbed away (updated the collection).

     

    First attempt:

    First I tried to use a "CreateDate" with a date/time stamp but PowerApps seems to only want to go down to the second.  So, if I hit "Add a Row" twice really fast, the two new rows are not unique in the collection, so that didn't work.  Then I tried to pass a value into my ID field when I add a new row.  So I pre-populated my ID field on every new row with a number.  However, when I tried to patch that back to my database I got an error because the ID field I used was also my Primary Key and Patch was looking for an existing record to update, which did not yet exist.

     

    Solution:

    Ultimately, I added a Collection ID field.  So instead of pre-populated my Primary Key field when I create a new record in the gallery, I pre-populated a CollectionID field.  This made unique rows in the collection without effecting my SQL Primary Key column.  Now, when I Patch back to SQL, everything works perfectly while letting users create as many new rows in the Gallery as they need at once.

     

    Kind of a unique situation but I hope it helps someone else.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard