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

Submitting new record to SQL Server with GUID

Hi,

 

I am trying to submit a new record into SQL server which required a GUID. function. I tried inserting a default value in the datacard with the value GUID() but I receive an error that the AccountID is required.

 

I tried the following Patch function but keep receiving the following errors (Unexpected characters: Contain 'ParenClose' where Error is expected):

 

Patch(
'[dbo].[Account]', Defaults('[dbo].[Account]'),
{
Name: DataCardValue20_2.text,
Surname: DataCardValue38_2.text,
Group: DataCardValue4_2.text,
Passport No: DataCardValue36_2.text,
Tel No: DataCardValue39_2.text,
Cell No: DataCardValue2_2.text,
ID No: DataCardValue5_2.text,
Nationality: DataCardValue21_2.text,
Relationship: DataCardValue37_2.text,
Email Address: DataCardValue3_2.text,
Initials: DataCardValue19_2.text,
Notes: DataCardValue35_2.text,
AccountID: GUID()
}
)

 

What could be the problem with the above Patch statement? Is there any other way to submit a new record with GUID?

 

Thanks in advance.

1 REPLY 1
timl
Super User
Super User

Hi @wschel 

Part of the problem is that for column names with spaces, you need to enclose the column names in single quotes. The column names are also  case sensitive, so the names you provide will need to match the case of your source columns.

The following should hopefully take you further.

Patch(
      '[dbo].[Account]', 
      Defaults('[dbo].[Account]'),
      {
         Name: DataCardValue20_2.Text,
         Surname: DataCardValue38_2.Text,
         Group: DataCardValue4_2.Text,
         Passport No: DataCardValue36_2.Text,
         'Tel No': DataCardValue39_2.Text,
         'Cell No': DataCardValue2_2.Text,
         'ID No': DataCardValue5_2.Text,
         Nationality: DataCardValue21_2.Text,
         Relationship: DataCardValue37_2.Text,
         'Email Address': DataCardValue3_2.Text,
         Initials: DataCardValue19_2.Text,
         Notes: DataCardValue35_2.Text,
         AccountID: GUID()
       }
)

 

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,216)