cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
twilde
Level: Powered On

Help! How to write to SQL Datatable with auto generated GUID as PK

Hi,

 

im fairly new to Powerapps and im trying to build an App that lets me view, edit, create and delete Entries in a SQL Table.

The way i currently try to do is using a datatable form in powerapps to view and select data und a editForm to edit it, using the submitForm function, which works just fine.

 

My Problem lies in creating new entries (im using a button with the function newform and then another with submitform for that currently). The thing is, that i have to leave the field empty or not submit it at all, because the guid is generated by the database, but it doesnt work with submitting null because its a key attribute. I also tried writing a view that gives me a new GUID and import that directly to powerapps, but i cant figure out how to use that to set the value in my edit form to that value from the view.

 

I have been struggling at this for quite a while now and I hope that someone knows a solution.

2 REPLIES 2
mr-dang
Level 10

Re: Help! How to write to SQL Datatable with auto generated GUID as PK

Hi @twilde,

Can you tell me more about how/when you generate the GUID? What system have you set up for having it inserted or modified into the field?

Microsoft Employee
@8bitclassroom
twilde
Level: Powered On

Re: Help! How to write to SQL Datatable with auto generated GUID as PK

Hello, sorry for not answering earlier, but i have been occupied on something else this week, but now im back at working on my powerapps.

 

The guid is generated through a default constraint in the sql datatable which sets the default value to newid().

I have found a workaround for it though, by creating a view that gives a newid(), loading that view into powerapps to a datatable and setting the default value in my edit form to either the value selected in the datable i use for my databse im working on, or if empty (because of the command newform())to the value from the view, which i then refresh to always generate a new guid. it works, but now i have got a different problem with one of the other values that are configured as not null in the datatable, but are not supposed to be inserted and instead filled with default values.

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (4,724)