Skip to main content
Community site session details

Community site session details

Session Id : HcFOFC2Tdv5n1iTtA5wFPx
Power Apps - Microsoft Dataverse
Answered

Choice Patch from Grid Command PowerFx

Like (0) ShareShare
ReportReport
Posted on 11 Apr 2024 08:51:18 by 34

Hi All,

 

I'm struggling to figure out how to patch a Choice column from a Grid (PowerFx) command. To keep it simple, I created a test App with a single table called 'Project' with a couple of columns, one of which is a Choice ('Started' or 'Finished') column.

 

I've created a Command to run from the Projects grid. It should patch the selected records changing the current Choice column (ProjectStatus) to 'Finished'. 

 

I can patch the Choice column using ThisRecord.ProjectStatus (pointless I know) with no error, but I can't work out how to present a record object for the choice 'Finished' to update the ProjectStatus column.

 

innes_NZ_1-1712824089019.png

 

Below is a screenshot of the error that is returned when trying to patch the ProjectStatus column in the Projects table.  

 

innes_NZ_0-1712823725597.png

 

What is the correct syntax to update the ProjectStatus column to reflect the new status of 'Finished'?

 

Cheers, Innes (NZ)

 

Categories:
  • Verified answer
    innes_NZ Profile Picture
    34 on 11 Apr 2024 at 21:44:00
    Re: Choice Patch from Grid Command PowerFx

    Hi All,

     

    It turned out to be remarkably simple to get this Patch example to work:

     

    Patch(Projects, ForAll(Self.Selected.AllItems,
    {
        Project:ThisRecord.Project,
        'Report Generation Status':"trigger" & Rand(),
        ProjectStatus: ProjectState.Finished
    }))
     
    ProjectState.Finished returned an object that satisfied the syntax requirement to patch the ProjectStatus Choice column in the Projects table.
     
    Thanks all for the help, and hopefully this will help someone else to get their head around this particular issue.
     
  • innes_NZ Profile Picture
    34 on 11 Apr 2024 at 18:21:40
    Re: Choice Patch from Grid Command PowerFx

    Hi @Jmanriquerios ,

     

    Thanks for replying. It's much appreciated.

     

    It's unclear which column is being patched with the Choice value.  Could you please highlight which part of the code snippet sets the patched Choice column in Control Financieros and from what source.

     

    Thanks in advance.  Innes (NZ)

  • Jonathan Manrique Profile Picture
    2,682 on 11 Apr 2024 at 10:03:49
    Re: Choice Patch from Grid Command PowerFx

    Hi @innes_NZ 

     

    As an example, it happened to me, and until I found a solution

     

    ForAll(
     Self.Selected.AllItems As tblsPagoProfesor;
     Patch(
     'Control Financieros';
     Defaults('Control Financieros');
     {
     Concepto: tblsPagoProfesor.Nombre;
     'Tipo de Registro': 'Tipo de Registro'.Gasto;
     'Tipo de Gasto': 'Tipo de Gasto'.'Pago de Profesor';
     'Fecha Registro': tblsPagoProfesor.'Fecha de pago';
     Monto: tblsPagoProfesor.Monto;
     'Pago Profesores (jm_PagoProfesores)': tblsPagoProfesor
     }
     )
     )

     

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Featured topics

Loading complete