cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MBlythe2020
Frequent Visitor

Patch or Collect Not Working due to SQL Table ID Column

Hi All,

 

I have a SQL table: ActionsDB

 

It has 12 columns. One of which is called ID and is set to (PK, int, not null)

 

My app has a collection called Actions. Where the user submits information pertaining to the columns e.g. Action Description.

 

Once they are complete I'd like them to be able to submit this to the table. Potentially more than one row at a time as there could be multiple actions.

 

I'm having zero luck getting around the ID column. It autogenerates within the SQL Table which is required to edit the data in PowerApps.

 

I've tried:

 

  • Collect('[dbo].[ActionsDB]',Actions)
  • ForAll, Patch etc 

What am I missing? If I open a new form I can edit straight in but this isn't the desired effect I would like for the app or user.

 

None of the formulas show an error once completely written out, columns all match.

3 REPLIES 3
mike528
Resolver II
Resolver II

@MBlythe2020 

 

So what you are seeing is the patch does not actually insert a table into the DB? There are couple of things you can try, first, turn on the PowerApps monitor, this will allow you to see all calls to the DB with what is sent and what comes back. 

 

I typically use the Patch command when writing to SQL or passing JSON for multiple records to a Flow that calls a stored procedure and let the stored proc do all the work.

 

Hope this help.

 

This is my formula:

 

ForAll(Actions,Patch('[dbo].[ActionsDB]',Defaults('[dbo].[ActionsDB]'),{ActionDesc:ActionsActionDesc,ActionEmail:ActionsActionEmail,ActionOwner:ActionsActionOwner,Actionsource:ActionsActionsource,IssuedBy:ActionsIssuedBy,issuedbydate:Actionsissuedbydate,issuedbyemail:Actionsissuedbyemail,ItemNumber:ActionsItemNumber,PriorityLevel:ActionsPriorityLevel,SOTSection:ActionsSOTSection,StatusMain:ActionsStatusMain,TBCDATE:ActionsTBCDATE}))

 

All I get is "ID: Field 'ID' is Required"

Is your ID field set as an Identity where the ID is auto assigned? If not, this is your issue.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,685)