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 / Duplicate entry for ke...
Power Apps
Unanswered

Duplicate entry for key primary MySQL

(0) ShareShare
ReportReport
Posted on by 8

Hi, i have a issue when i patch into forall function. My datasource is Mysql this database is relational and i use a gallery with checkbox, in this checkbox show a skill description, so when the user press the boton i should insert all checked value but, i use patch function into forall the server show error. My code is next:

 

ForAll(Checked;Patch('DB_DEV_SIC.vco_prospectohabilidades';Defaults('DB_DEV_SIC.vco_prospectohabilidades');{idhabilidadtecnologica:LookUp('DB_DEV_SIC.vcc_habilidadestecnologicas';Descripcion = Checkbox2.Text;idhabilidadestecnologicas) ;idprospecto:v_idprospecto;idprospectohabilidades: v_idprospectohabilidades}))

 

The error is "Duplicate entry '1' for key primary".

error_1.png
checkbox_2.png
Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Ing_Jesus_Lopez 

    To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  ForAll is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    What is the name of your primary key column?  And, what is "Checked" in your formula?  If it is some sort of collection, what is the definition of the collection?

  • Ing_Jesus_Lopez Profile Picture
    8 on at

    Hello RandyHayes, my table contains 3 fields, idprospectohabilidades, idprospecto and idhabilidades. My primary key is idprospectohabilidades. I created a collection on start app with all skills description like Qlik View, Qlik Sense etc, this collection i called "HabilidadesTecnologicas".  In my gallery put a checkbox and in the items option, i  did reference to collection. After that in my button i need to insert each checkbox checked in the table in mysql with idprospectohabilidades(PK), idprospecto(FK) and idhabilidades(FK).

     

    Collection:

    Ing_Jesus_Lopez_0-1651706098567.png

    Gallery

    Ing_Jesus_Lopez_1-1651706176301.png

    OnCheck Checkbox. I created a new collection with all checkbox checked.

     

    Ing_Jesus_Lopez_2-1651706460451.png

    Text of the CheckBox

    Ing_Jesus_Lopez_3-1651706605301.png

    Button Onselect

     

    Ing_Jesus_Lopez_4-1651706671384.png

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard