When you build a Custom Page in Dynamics 365, you’ll constantly face one question: should this logic be Power Fx or JavaScript? Both can move data, open dialogs, and react to events — but each shines in different places. Choosing well keeps your app simple, fast, and easy to maintain.
This article — part of our series on hosting PCF controls in modal popups — compares Power Fx and JavaScript in Custom Pages, in plain language, so you always pick the right tool.
The Short Answer
- Power Fx lives inside the Custom Page. Use it for page logic: reading
Param(), showing/hiding controls, callingPatch(), and binding data to a PCF control. - JavaScript lives on the model-driven form. Use it for what happens outside the page: ribbon buttons, opening the dialog with
Xrm.Navigation.navigateTo(), and refreshing the form afterward.
In most real solutions, you use both together — JavaScript opens the page, Power Fx runs the page.
Where Power Fx Wins
- Low-code speed — build screens and logic without a build pipeline.
- Native Dataverse —
Patch(),Filter(), and galleries just work. - Reactive UI — controls update automatically when variables change.
- Maintainability — makers can update it without a developer.
Where JavaScript Wins
- Client API access —
Xrm.Navigation,formContext, ribbon rules. - Complex logic — loops, advanced string handling, external libraries.
- Form control — refresh subgrids, timelines, and ribbons after a dialog closes.
- Reuse — share one web resource across many forms.
A Side-by-Side Example
Opening a dialog is a JavaScript job (it needs the Client API):
// JavaScript on the form (ribbon button)
Xrm.Navigation.navigateTo(
{ pageType: "custom", name: "cr123_editor_page" },
{ target: 2, width: { value: 60, unit: "%" } }
);
Saving a record inside the page is a Power Fx job (it’s native and simple):
// Power Fx on the Custom Page (Save button)
Patch(Accounts, LookUp(Accounts, Account = gRecordId),
{ 'Account Name': txtName.Text, 'Main Phone': txtPhone.Text });
Back();
A Simple Decision Rule
Ask where the logic runs:
- Runs inside the page (UI, data, bindings)? → Power Fx.
- Runs on the form or needs the Client API (open dialog, refresh, ribbon)? → JavaScript.
- Heavy computation or an external library? → JavaScript (or a PCF control).
Conclusion
Power Fx and JavaScript aren’t rivals — they’re partners. Let JavaScript handle the form and the Client API, let Power Fx handle the page and Dataverse, and reach for a PCF control when you need rich, reusable UI. Match each tool to where the work happens and your Custom Pages stay clean and maintainable.
Related: Open a PCF Control in a Modal Popup Using Custom Pages. Want an architecture review of your Power Platform app? Talk to the CloudVerve team.