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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch() identical name...
Power Apps
Unanswered

Patch() identical named lookup columns in dataverse tables, using the context of an open form/modern commanding in model driven powerapps

(0) ShareShare
ReportReport
Posted on by 6

yozu_0-1703645384498.png

 

 

Want to create a Custom Command Button in the main form on CANDIDATE table, to copy Qualified candidates in the open form in a model drivel app, to Team table, upon Command button click. This is in the modern commanding in Model driven Powerapps (Not a Canvas app). This is a Dataverse table to table copy.

 

Both source and target tables have the same named lookup column "Country", and each is a lookup to the COUNTRY table by respective Candidate_Country and Team_Country relationships.

 

What is the Patch() expression that copies the current lookup value in CANDIDATE.COUNTRY to TEAM.COUNTRY, keeping in mind that the button is operating in the context of an open form/ selected record, and disambiguation may be required, given identical lookup column names?

 

Been banging my head on a wall and appreciate the community's help. Running into what I think are disambiguation issues. I tried with no joy:

Patch (TEAM, Defaults(Team),

{Country : CANDIDATE[@Country]}

)

Also had issues using a Lookup() and /or with disambiguation. Read through a lot of documentation and I either can get a direct answer, or examples related to canvas app collections, sharepoint, etc. This is a dataverse to table to table copy using a custom modern command which will have this patch statement in it. When user presses this command in an open form in a model driven app, the open [selected] record should copy over.

 

See screenshot for example.

 

Thanks in advance!

-yz

I have the same question (0)
  • Jonathan Manrique Profile Picture
    2,687 on at

    Hi @yozu 

     

    It is a little simpler than it seems, but we must know how to combine the formulas and above all one that should be used is With


    I show you an example code that allows you to clone and another that allows you to create

     

    If(
     Confirm(
     "Desea duplicar el registro con los siguientes datos: " & "Alumno: " & Self.Selected.Item.Alumno.'Nombre completo' & Char(10) & "Programa: " & Self.Selected.Item.Programa & Char(10) & "Asignatura: " & Self.Selected.Item.Asignatura;
     {
     Title: "Duplicar registro Pago Matricula";
     Subtitle: "¿Está seguro que desea duplicar el registro indicado?";
     ConfirmButton: "Aceptar";
     CancelButton: "Cancelar"
     }
     );
     With(
     {
     newRecord: Patch(
     'Pago de Matriculas';
     Defaults('Pago de Matriculas');
     {
     Alumno: Self.Selected.Item.Alumno;
     Sección: Self.Selected.Item.Sección
     }
     )
     };
     Navigate(
     LookUp(
     'Pago de Matriculas';
     Código = newRecord.Código
     )
     )
     );Notify(
     "No ha creado ningún registro duplicado";
     NotificationType.Information;
     4000
     )
    )

     

     

     

    If(
     Confirm(
     "Desea Crear un Registro de Control Financiero para : " & Self.Selected.Item.Alumno.'Nombre completo';
     {
     Title: "Registro Control Financiero";
     Subtitle: "¿Está seguro que desea crear un (1) registro?";
     ConfirmButton: "Aceptar";
     CancelButton: "Cancelar"
     }
     );
     With(
     {
     ControlFinanciero: Patch(
     'Control Financieros';
     Defaults('Control Financieros');
     {Concepto: Self.Selected.Item.Nombre};
     {'Tipo de Registro': 'Tipo de Registro'.Ingreso};
     {'Tipo de Ingreso': 'Tipo de Ingreso'.'Pago de Inscripción'};
     {'Fecha Registro': Self.Selected.Item.'Fecha de pago'};
     {Monto:Self.Selected.Item.'Total Inscripción'};
     {'Pago de Inscripción': LookUp('Inscripción Programas';Inscripción = Self.Selected.Item.Inscripción)}
     
     )
     };
     With(
     {
     ActualizarInscripcion: Patch(
     'Inscripción Programas';
     Self.Selected.Item;
     {'Control Financiero': ControlFinanciero};
     {Estado:'Estado (Inscripción Programas)'.Inactivo};
     {'Razón para el estado':'Razón para el estado (Inscripción Programas)'.'Control Financiero'}
     )
     };
     With(
     {
     Navegar: Navigate(LookUp('Control Financieros';'Pago de Inscripción'.Inscripción=Self.Selected.Item.Inscripción))
     };
     ControlFinanciero
     )
     
     ));
     Notify(
     "No ha creado a ningún registro de Control Financiero";
     NotificationType.Information;
     4000
     ))

    You can adapt it to your needs, but the key is to use with and know how to relate the lookup fields

     

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    You can accept more than one post as a solution

  • Verified answer
    ivan_apps Profile Picture
    2,187 Moderator on at

    Yea you have to pass in a ‘Record’ type value in the Patch. So instead of CANDIDATE[@Country] … you would put in ‘Self.Selected.Item.Country’

    Self.Selected.Item references the current open form so that’s what you are missing.

     

    now if for whatever reason Self.Selected.Items.Country doesn’t resolve to a ‘Record’ type, you would simply replace it with a Lookup(). For example:

    {Country : Lookup(Country, Name = Self.Selected.Item.Country.Name)}

     

    using the With() function is sometimes necessary to stage the lookup as a variable before executing the Patch command.

    ex:

    With(

    {

    varLookupResult: lookup(…) 

    },
    Patch([reference varLookupResult here])

    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard