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 / AutoGen Mandatory DB2 ...
Power Apps
Answered

AutoGen Mandatory DB2 field blocking an INSERT

(0) ShareShare
ReportReport
Posted on by 27

I have a PowerApps CRUD sopun up from a DB2 batabase wich has an ID field that is set to defined as generated always. Even if I set the ID field's Requierd to False in my App or remove the data card it fails to exicute the INSERT. Strangly the App will save an edit of a record. I have no idea where to from here.

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @sludgeza ,

    Do you set the ID as Requried/Mandatory field within your DB2 table?

     

    Based on the issue that you mentioned, I think you have some misunderstanding on data sources in PowerApps.

     

    Actually, the PowerApps app inherits data access permissions from data source itself. The Edit form data cards would be generated based on data source itself.

    If you set the ID as Requried/Mandatory field within your DB2 table, you must provide a value for this field wthin your Edit form.

     

    As an an fixed solution, please consider set the Default property of the Text Input box within the ID data card in your Edit form to following:

    First(Sort('Your DB2 Table', ID, Descending)).ID + 1

    Set the OnSelect property of the "Submit" button to following:

    Refresh('Your DB2 Table'); /* <-- Add this formula */
    SubmitForm(EditForm1) /* <-- EditForm1 represents the Edit form in your app */

    Best regards,

  • sludgeza Profile Picture
    27 on at

    OK this works :

    As an an fixed solution, please consider set the Default property of the Text Input box within the ID data card in your Edit form to following:

    First(Sort('Your DB2 Table', ID, Descending)).ID + 1"

     But... The insert still fails with the same message that the ID field is defined as ALWAYS GENERATED. I find this odd as the edit function works where the ID field is populated on my PowerApps form but in the create form it fails. The ID field in the db2 is the Primary Key so I'm not sure if this bit of architectuer of the db2 can be changed.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    HI @sludgeza ,

    Please consider edit your DB2 Table, and then remove the Auto-Generate attribute from the ID field. Then re-generate an app based on the DB2 table, try my above solution again (set Default value for ID field using formula), check if the issue is solved.

     

    Best regards,

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 377 Most Valuable Professional

#2
11manish Profile Picture

11manish 165 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 110 Super User 2026 Season 2

Last 30 days Overall leaderboard