web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problems with patch fu...
Power Apps
Answered

Problems with patch function in connection SQL database and POWERAPPS

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I made a form and when i try to insert (record) form data to SQL database , although the data are new valor (not recorded yet on sql databse), 

I get this error:

"the element have been yet created on server"

and the new data are not recordes on sql database.

The sentence I use on form.Onselect is

"If(!IsEmpty('[dbo].[Personal]');Patch('[dbo].[Personal]';Defaults('[dbo].[Personal]');{'PRIMER APELLIDO':
Value(TextInput_PrimerApellido.Text);MATRICULA:Value(TextInput_Matricula.Text)})) "

Thanks.

Categories:
I have the same question (0)
  • timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @Anonymous 

    I'm not quite certain as to the cause of this problem. 

    A common cause of not being to add records to SQL Server is when tables are missing primary keys.

    Can you confirm that '[dbo].[Personal]' has a primary key?

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Could you please share a bit more about the 'PRIMER APELLIDO' column and MATRICULA column in your SQL Table? Are they unique columns in your SQL Table or Primary Key in your SQL Table?

    Have you defined a Primary Key within your SQL Table ('[dbo].[Personal]')?

     

    I have made a test on my side, and don't have the issue that you mentioned.

    Please check if the 'PRIMER APELLIDO' column and MATRICULA column are unqiue columns in your SQL, if true, I think this is the issue with your Patch functon. The unique columns in a SQL Table could not be allowed to provided a repeated values.

     

    In addition, please also check if you have defined a proper PRIMARY KEY within your SQL Table. If you do not define a PRIMARY KEY in your SQL Table, the Patch function would not work when patching data into your SQL Table.

    The user @TesDA has faced same issue with you, please check my response within the following thread:

    https://powerusers.microsoft.com/t5/General-Discussion/Error-creating-new-row-This-item-has-already-been-created-on-the/m-p/285211#M82566

     

    Please make sure that you have defined a proper PRIMARY KEY in your SQL Table. Please also consider delete your SQL Table, then re-create it again with proper PRIMARY KEY, re-create a new connection to the new SQL Table within your app, try your formula again, check if the issue is solved.

     

    There are some limits with SQL Server connector in PowerApps, please check the following article:

    https://docs.microsoft.com/en-us/connectors/sql/#known-issues-and-limitations

     

    Best regards,

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous wrote:

    I made a form and when i try to insert (record) form data to SQL database , although the data are new valor (not recorded yet on sql databse), 

    I get this error:

    "the element have been yet created on server"

    and the new data are not recordes on sql database.

    The sentence I use on form.Onselect is

    "If(!IsEmpty('[dbo].[Personal]');Patch('[dbo].[Personal]';Defaults('[dbo].[Personal]');{'PRIMER APELLIDO':
    Value(TextInput_PrimerApellido.Text);MATRICULA:Value(TextInput_Matricula.Text)})) "

    Thanks.



    Problem resolved.

    After setting the primary key on SQL '[dbo].[Personal]' table, and a couple of tryings, finally I succeed on it.

    The complete sentence I use on form.Onselect was:

    If(!IsEmpty('[dbo].[Personal]_1');Patch('[dbo].[Personal]_1';Defaults('[dbo].[Personal]_1');{COLUMN1:ComboBox_Negocio_Alta_UI.Selected.Result;COLUMN2:ComboBox_Pais_Alta_UI.Selected.Result;COLUMN3:ComboBox_Localidad_Alta_UI.Selected.Result;'COLUMN4':'TextInput_NIF_Alta_UI'.Text;EMAIL:TextInput_Email_Alta_UI.Text;NAME:TextInput_Nombre_Alta_UI.Text;'PRIMER APELLIDO':
    TextInput_PrimerApellido_Alta_UI.Text;'SEGUNDO APELLIDO':TextInput_SegundoApellido_Alta_UI.Text;'PERFIL DE EMPLEADO':ComboBox_PerfilEmpleado_Alta_UI.Selected.Result;'NIVEL DE SEGURIDAD':ComboBox_NivelSeguridad_Alta_UI.Selected.Result;'RESPONSABLE':'TextInput_Jefe/Responsable_Alta_UI'.Text;'TIPOEMPLEADO':ComboBox_TipoEmpleado_Alta_UI.Selected.Result;'ENTITY':ComboBox_Entity_Alta_UI.Selected.Result;MATRICULA:TextInput_Matricula_Alta_UI.Text}))

     

    Thanks for your help

    Regards!


    @Anonymous wrote:

    I made a form and when i try to insert (record) form data to SQL database , although the data are new valor (not recorded yet on sql databse), 

    I get this error:

    "the element have been yet created on server"

    and the new data are not recordes on sql database.

    The sentence I use on form.Onselect is

    "If(!IsEmpty('[dbo].[Personal]');Patch('[dbo].[Personal]';Defaults('[dbo].[Personal]');{'PRIMER APELLIDO':
    Value(TextInput_PrimerApellido.Text);MATRICULA:Value(TextInput_Matricula.Text)})) "

    Thanks.


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard