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

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.

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
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

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.


Power Apps Community User Group Member Badge

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


Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.


Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,939)