# When should I use Power Fx or JavaScript for a model-driven command?

Exam: AB-400 — Power Platform Developer Associate
Knowledge domain: Extend the user experience (25–30%)
Updated: 2026-11-25T06:47:18.414962+00:00
HTML: https://learningpathx.com/faq/AB-400/ab400-model-driven-commands-power-fx-or-javascript.html

## Also asked as

- Should I use Run formula or a JavaScript action in the model-driven command designer?
- How do I choose a model-driven command action and test its selection behavior?

Use Power Fx when a supported formula can express the command's action or visibility. Choose JavaScript for an action that needs the model-driven Client API or explicit asynchronous coordination. Check the command's location and selection contract first.

For example, a reminder can run a formula such as `Notify("Review the saved credit hold before requesting approval.")`. Give the command accessible text, save and publish, and wait for the command component library to finish publishing. Refresh the running app and test with an intended user who has the app and command library access and the relevant Dataverse roles.

Check main form, main grid and subgrid behavior separately. An action expecting one row should require exactly one selection. Power Fx commanding has a default form-buffer AutoSave behavior. Test that behavior and the supported formula functions at the actual command location before promising that a button leaves unsaved edits alone. Treat command visibility as a display decision and enforce permission at the operation.

[Command designer overview](https://learn.microsoft.com/en-us/power-apps/maker/model-driven-apps/command-designer-overview) · [Power Fx in model-driven commands](https://learn.microsoft.com/en-us/power-apps/maker/model-driven-apps/commanding-use-powerfx)

Source: [AB-400: Client Scripting and Commands in Model-Driven Apps](https://learningpathx.com/news/ab-400-client-scripting-and-commands-in-model-driven-apps.html)
