cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

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

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
Highlighted
Regular Visitor

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
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 (7,326)