Power-Fx icon indicating copy to clipboard operation
Power-Fx copied to clipboard

REPL: [pac pfx] Add Support for inserting records with Patch and Defaults

Open scottdurow opened this issue 2 years ago • 4 comments

Currently, if you use the following Power Fx with pac pfx:

Patch(Accounts,
    Defaults(Accounts),
    {
        'Account Name':"Test"
    }
);

It will fail with the error 'Defaults' is a recognized but not supported function. This is not surprising since Defaults is not listed as a supported function at https://aka.ms/Power-Fx-PAC-CLI

If you omit the Defaults, then it gives the error Error 0-57: Invalid number of arguments: received 2, expected 3 or more.

The work around is to use Collect instead, however folks are mostly used to using Patch with Defaults as described by https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-patch#overview

Can support for Inserting records using Patch and Defaults be added?

scottdurow avatar Nov 18 '23 01:11 scottdurow

We have https://github.com/microsoft/Power-Fx/issues/1550 under development which will unify Collect/Patch/Clear/ClearCollect functions with the Power Apps overloads. No ETA.

anderson-joyle avatar Nov 20 '23 01:11 anderson-joyle

Hi @anderson-joyle, any update on the ETA to support Patches and Defaults? Thanks

ericregnier avatar May 30 '24 13:05 ericregnier

Hi @anderson-joyle, any update on the ETA to support Patches and Defaults? Thanks

The Patch function has all overloads available in Power Fx. Not sure if the changes made their way to PAC. I'll check and let you know. Defaults is still not available. There's no ETA right now. I'll push some internal conversations.

anderson-joyle avatar May 30 '24 16:05 anderson-joyle

The work around is to use Collect instead

Thanks, I've just come up against this as Patch seems to be the natural way to do it and using Patch with Default is the way described in the docs. It would make using the library and CLI more straightforward if Defaults could be added, but failing that could a note be added to the Patch and Defaults docs to indicate that Collect is the preferred way of creating a record?

MarkMpn avatar Jul 09 '24 15:07 MarkMpn