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 / Issue with Patch Funct...
Power Apps
Answered

Issue with Patch Function when Trying to Add Data

(0) ShareShare
ReportReport
Posted on by 71

I'm facing an issue with the Patch function in Power Apps when attempting to add data to the JerarquíaGeográfica table.

I have three dropdowns, drpPaises, drpClanes, and drpConsejos, and I want to create a new record in the JerarquíaGeográfica table using values selected from these dropdowns. Here's the formula I'm using:

 

Patch(JerarquíaGeográfica, Defaults(JerarquíaGeográfica),

{
    IDPais:{Id: drpPaises.Selected.ID, Value: drpPaises.Selected.DescripcionPais},
    IDClan:{Id: drpClanes.Selected.ID, Value: drpClanes.Selected.DescripcionClan},
    IDConsejos:{Id: drpConsejos.Selected.ID, Value: drpConsejos.Selected.DescripcionConsejo}
   }
);

 

These 3 columns are of the Lookup type in the JerarquíaGeográfica table.

 

Regards

 

Categories:
I have the same question (0)
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @galvang , Can you try below:

     

    Patch(JerarquíaGeográfica, Defaults(JerarquíaGeográfica),
    {
     IDPais: {Value: drpPaises.Selected.DescripcionPais},
     IDClan:{Value: drpClanes.Selected.DescripcionClan},
     IDConsejos: {Value: drpConsejos.Selected.DescripcionConsejo}
     }
    );

     

    OR

     

    Patch(JerarquíaGeográfica, Defaults(JerarquíaGeográfica),
    {
     IDPais: drpPaises.Selected,
     IDClan: drpClanes.Selected,
     IDConsejos: drpConsejos.Selected
     }
    );

     

    If this doesn't work, then please share the screenshot. Also share the information of item property of all dropdowns.

    -----------------------------------------------------------------------------------------------------------------------------
    I hope this helps.
    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.
    Thanks,
    ANB

  • galvang Profile Picture
    71 on at

    hi @ANB ,

    Unfortunately it didn't work.

     

    DROPDOWN:

    - Items properties drpPaises(Based on which user joins the countries related to their Role): 

    With(
    {_ID:LookUp(Usuario,EmailPersona.Email = User().Email).ID},
    Distinct(AddColumns(Filter('Usuario - Paises',IDUsuario.Value = _ID), "CtyID",IDPaises.Value),
    CtyID))

     

    -Items properties drpClanes  

    Distinct(Clanes, DescripcionClan)

     

    - Items properties drpConsejos

    Filter(Consejos, IdClan.Value = drpClanes.Selected.Value)

     

    scr1.png

     

    TEXTINPUT in the GALLERY:

     

    - Default properties txtPaisesClanLocal

    ThisItem.IDPais.Value

     - Default properties txtClanesClanLocal

    ThisItem.IDClan.Value

    - Default properties txtCosejosClanLocal

    ThisItem.IDConsejo.Value

    The idea is to select one from each dropdown and add it to the gallery and the JerarquíaGeográfica database, using the save button.

     

    regards,

    Ângelo

     

  • Verified answer
    WarrenBelz Profile Picture
    156,434 Most Valuable Professional on at

    @galvang ,
    Adding some input here and asking if you really need those to be lookup columns unless you are using them directly in Edit in Grid view in (I assume you are using) SharePoint as this is a great example of the chaos they can unnecessarily cause when the Items of the drop-downs are also changed and you no longer have the Id value to write back to the field. From what you have posted, I think the first two are correct, but you have not stated the field name in Consejos that drpConsejos is looking up, so I have used DescripcionConsejo which may not be correct.

    Patch(
     JerarquíaGeográfica, 
     Defaults(JerarquíaGeográfica),
     {
     IDPais:
     {
     Id:
     LookUp(
     'Usuario - Paises',
     IDPaises.Value = drpPaises.Selected.DescripcionPais
     ).ID,
     Value: drpPaises.Selected.DescripcionPais
     },
     IDClan:
     {
     Id:
     LookUp(
     Clanes, 
     DescripcionClan = drpClanes.Selected.DescripcionClan
     ).ID,
     Value: drpClanes.Selected.DescripcionClan
     },
     IDConsejos:
     {
     Id:
     LookUp(
     Consejos, 
     DescripcionConsejo = drpConsejos.Selected.DescripcionConsejo
     ).ID,
     Value: drpConsejos.Selected.DescripcionConsejo
     }
     }
    );

     

  • galvang Profile Picture
    71 on at

    I am not sure if my messages are going through since I marked the previously response as "Accept as Solution".

     

    Patch function is working.

    But In the drpConsejos, regardless of the value I select, it always saves with the first value in the dropdown.

    IDConsejo:
    {
              Id:
              LookUp(
              Consejos,
              IdClan.Value = drpClanes.Selected.Value
        ).ID,
            Value: drpConsejos.Selected.DescripcionConsejo
    }

     

    Don't know how to solve it. 

     

    Regards

  • WarrenBelz Profile Picture
    156,434 Most Valuable Professional on at

    @galvang ,

    Are you saying this is a multi-select dropdown ? If so this gets even messier

    IDConsejos:
    ForAll(
     drpConsejos.SelectedItems As _Sel,
     {
     Id:
     LookUp(
     Consejos, 
     DescripcionConsejo = _Sel.DescripcionConsejo
     ).ID,
     Value: _Sel.DescripcionConsejo
     }
    }

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 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard