cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sludgeza
Helper I
Helper I

AutoGen Mandatory DB2 field blocking an INSERT

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,521)