Hi there,
I am working on implementing a custom button in a model driven app which duplicates whichever records are currently selected. It has the OnSelect code of:
IfError(
ForAll(Self.Selected.AllItems,
Patch(Milestones, Defaults(Milestones),
{
'Project Name': "Copy of " & ThisRecord.'Project Name',
'Expected Start Date': ThisRecord.'Expected Start Date',
Project: ThisRecord.Project,
Currency: ThisRecord.Currency
}
)
);
Notify("The selected item(s) have been copied successfully!", NotificationType.Success, 5000),
Notify("Failed to copy the selected item(s). Please try again.", NotificationType.Error, 5000)
);
Currency is a Lookup column to the OOTB Currency table.
When I exclude the Currency column from this code (so when the code only has Project Name, Expected Start Date and Project) it works perfectly, but with the Currency column I get this error:
From what I can tell, the error isn't happening because Currency is a Lookup column, as Project is also a Lookup column and there is no issue when copying that field to the new record.
For anyone who has been configuring custom buttons in model-driven app buttons recently you may be aware that it wasn't working for anyone until Microsoft rolled out a fix just a few days ago so I wonder if that is playing a part in this bug? You can read more about this here: Dataverse Model Driven App Command Bar Power FX Bu... - Power Platform Community (microsoft.com)