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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,948)