Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

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



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.

Community Champion
Community Champion

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

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

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users


We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (25,864)