Model-driven app button customizations used to be a challenging process, often involving third-party tools and custom code. However, with the Command Bar editing capability now available, we can easily introduce custom functionality to their apps using just a few lines of Power Fx.
In this blog post, we’ll create a powerful Power Fx Button that clones records in a responsive way.
Cloning a record
We want to make our button as responsive as possible. First, we will show form notifications to let the users know the process has started. Then, we will clone the record and navigate to the new cloned record.
We will use the Language() function to read the user’s language settings and show the message accordingly.
Showing form notification
Notify(
If(Language() = "en-US"
,"A copy of the selected record, " & Self.Selected.Item.Name & ", is being created. Please wait"
,"Eine Kopie des Datensatz , " & Self.Selected.Item.Name & ", wird erstellt.Bitte warten Sie.")
,NotificationType.Information,1000
);
Navigating to the cloned record
Navigate(
Patch(
'PPA Overviews'
,Defaults('PPA Overviews')
,{Name:Self.Selected.Item.Name & " (Copy)"}
)
);
Showing success message
Notify(
If(Language() = "en-US"
,"A copy of the selected record, " & Self.Selected.Item.Name & ", has been created."
,"Eine Kopie des ausgewählten Datensatz, " & Self.Selected.Item.Name & ", wurde erstellt.")
,NotificationType.Success
);
Leave a comment