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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create record in SQL w...
Power Apps
Answered

Create record in SQL with auto-incrementing PK

(0) ShareShare
ReportReport
Posted on by 41

I've built several apps connected to SPO data and am now trying to build my first app connected to SQL data. The DB in question supports our ERP. The first table I am trying to connect to and create a record in was created by our ERP system. Within the table, there are three columns that have auto-generated IDs, including the PK. I cannot figure out how to create the record via PowerApps and then allow SQL to generate the appropriate IDs. Any suggestions?

Categories:
  • Pablo Roldan Profile Picture
    316 on at

    Hi @JamesWo,

    You need follow these,

    1. Add a connection to SQL to powerapps
    2. Select the TABLE you want to use
    3. Add a Edit Form control.
      Set Form's  name as myForm (name as you want)
      Set Form's  property  Default mode to New
      Set Form's  property  Data Source to YOUR SELECTED TABLE IN 2nd STEP
    4. Select the fields you want to display in the form
    5. Add a Button And Place this formula to the OnSelect porperty

     

    SubmitForm(myForm)

     

    myForm  is the name of your added Edit Form

    regards.

  • JamesWo Profile Picture
    41 on at

    Sorry, I should have been more clear. I've got the form all completed since that process is identical regardless of the data source. My issue is that there are a few columns that are auto-generated, one of them being the PK field. They are also non-null fields so when I submit a form, the data isn't written to the table.

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @JamesWo

    The typical way to define auto-incrementing values with SQL Server is to define an int column and to enable the identity option, like I describe in this post.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Patch-is-asking-for-required-column/m-p/1263939

     

    I imagine those missing values are created by your ERP system, rather than by SQL Server. This is because SQL Server will automatically create server generated values without us needing to do anything extra in Power Apps.

     

  • Verified answer
    JamesWo Profile Picture
    41 on at

    That makes sense. Let me dig into that.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard