Use Power Fx in Power Pages (Preview)

Use Power Fx in Power Pages (Preview)

Power Fx is the low-code language used across the Microsoft Power Platform to express business logic. It is a general-purpose, strongly typed, declarative, and functional programming language.

Power Fx is written in human-friendly text and is designed to be authored directly by makers using an Excel-like formula bar. Its concise syntax makes it easy for both citizen developers and professional developers to build dynamic behavior.

Note:
Power Fx syntax in Power Pages requires formulas to begin with an equals sign (=), similar to Excel. This syntax might differ from what you are used to in Power Apps or Power Automate.

Power Fx enables collaboration across no-code, low-code, and pro-code teams by allowing logic to be written in a consistent and readable manner.

Important:
This is a preview feature. Preview features are not intended for production use and may have limited functionality. Power Fx in Power Pages is available starting from version 9.6.5.x.

Use Power Fx in Power Pages

Within a Power Pages website, Power Fx can be used as an expression language for specific components. It allows component properties to be dynamically evaluated based on Power Fx expressions.

Component Supported Properties
Text Text
Image Image URL, Alt Text
Button Button URL, Button Text
Iframe Iframe URL

Using the Power Fx Formula Bar

Components that support Power Fx include a new fx option in the toolbar. Selecting this option opens the Power Fx formula bar where expressions can be authored.

Formula Bar Components

  • A dropdown to select available component properties
  • A multiline expandable textbox for writing Power Fx formulas
  • A Reset button to revert the property to its default value
  • A Save button to persist the formula and immediately update the canvas

Formula Bar Developer Experience

The Power Fx formula bar includes several developer-focused features to improve productivity:

  • Autocomplete assistance: Suggests functions, parameters, tables, and objects. You can press Ctrl + Space to invoke it manually.
  • Problem detection: Early validation highlights errors in formulas to assist with debugging.
  • Unsaved changes dialog: Appears when navigating away with unsaved formula changes, allowing you to go back or discard changes.

Important Considerations

Start with an Equals Sign

Static text can be entered directly. However, Power Fx expressions must begin with an equals sign.

=Concatenate("Hello, ", User.FullName)
  

Secure Access to Dataverse Tables

Dataverse tables are accessed securely using Power Fx formulas. Ensure appropriate table permissions are configured before use. The current site user context is available through the User object.


=Concatenate(
  "Hello, ",
  First(Filter(Contacts, Contact = User.DataverseUserId)).'First Name',
  "!"
)
  
Note:
The User object represents a Power Pages user and does not expose the same properties as the User function in Power Apps.

Insert Dynamic Values Inside Text

To embed a dynamic value inside static text, use the following syntax:

This text ${expression} includes a dynamic value
  

Example:

The total number is ${Sum(10, 20)}
  

Known Issues and Limitations

  • Some Power Fx functions shown in IntelliSense are not currently supported in Power Pages and may display a design-time error.
  • The User object is not initialized for anonymous users, which may cause errors. This will be addressed in a future release.
  • Button and Image URL properties may not work correctly with formulas containing double quotes in versions earlier than 9.6.5.x.

Frequently Asked Question

Should I use Power Fx instead of Liquid?

Power Fx supports certain dynamic data scenarios in a low-code manner that can also be achieved using Liquid. Since Power Fx is currently in preview, it is recommended for experimentation and development environments. Liquid is a generally available feature and offers broader capabilities, making it the preferred choice for production and complex scenarios.

Comments

Popular posts from this blog

Part 1: Creating Code Apps in Power Apps - A step-by-step guide (with real errors I faced & how I fixed them)

Calling Microsoft Graph API from Power Automate Using Azure App Services – Step-by-Step Guide

Step-by-Step Guide: Power Automate Custom Connector Using Graph API from Azure App Service