cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: AutoGen Mandatory DB2 field blocking an INSERT

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
Highlighted
Community Support
Community Support

Re: AutoGen Mandatory DB2 field blocking an INSERT

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.
Highlighted
Helper I
Helper I

Re: AutoGen Mandatory DB2 field blocking an INSERT

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.

Highlighted
Community Support
Community Support

Re: AutoGen Mandatory DB2 field blocking an INSERT

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (10,030)