Model Driven Apps (Part 4)

Model-driven apps Power FX

Power FX

Power FX is a domain-specific programming language developed by Microsoft for creating custom expressions and formulas in various Microsoft products and services, primarily within the Power Platform ecosystem. The Power Platform includes tools like Power Apps, Power Automate (formerly known as Microsoft Flow), Power BI, and Power Virtual Agents. Power FX is designed to be a low-code language, which means it is designed to be user-friendly and accessible to people with limited programming experience.

Key features and characteristics of Power FX include:

Formula Language: Power FX is primarily a formula language used for creating expressions and calculations within the Power Platform applications. Users can write formulas to manipulate data, create custom business logic, and automate processes.


Excel-Like Syntax: Power FX has a syntax that is similar to Microsoft Excel formulas, making it familiar to users who are already comfortable with Excel.


Integration: Power FX is tightly integrated with various Microsoft products and services, allowing users to create custom logic and automation within their applications and workflows.


Low-Code: Power FX is designed to be accessible to users who may not have extensive programming experience. It aims to simplify the process of creating custom logic without the need for traditional coding skills.


Extensibility: Power FX can be extended with custom connectors and functions, enabling users to integrate with external systems and services.


Cross-Platform: While initially designed for the Power Platform, Microsoft has plans to make Power FX available in other products and services, further expanding its reach.


Power FX is intended to empower business users and citizen developers to create customized solutions and automate processes within the Microsoft ecosystem. It provides a way to add flexibility and automation to applications and workflows without the need for extensive software development.

Clone a Record

I used Power FX to add a Clone button to my Project Model Driven App's Main Form Command Bar.

I selected Projects view and selected the "Edit command bar" menu item

I selected the Main form command bar

I added a new command

I named the command Clone, selected the Clone Icon and selected the Run formula action

I selected the Show on condition from formula visibility option

I only wanted the Clone command to be visible when the State...

... was not FormMode.New

I clicked the Save and Publish button

The Clone command does not appear when the user is creating a new record

The Clone command appears when the user is viewing an existing record

I updated the Run formula action

Power FX

With(
    {
        project: Patch(
            Projects,
            Defaults(Projects),
            {'Business Need': Self.Selected.Item.'Business Need'}
        )
    },
    Navigate(project);
    Notify("Project Item Copied")
);

I clicked the Save and Publish button and the Play button

I opened an existing record and clicked the Clone button

The Power FX formula created a new record (using record defaults and the original record's Business Need value), navigated the user to the new record and displayed a "Project Item Copied" message.

The browser's developer tools shows the JavaScript generated from the Power FX formula