Understand AutoSave

Completed

Under specific conditions, selecting a command bar command before its action logic runs will automatically save the form’s data. This AutoSave behavior only applies when you configure the command to use Power Fx. If you use JavaScript for the command logic, no automatic save occurs.

Commands that use Power Fx are configured by default to automatically save form data before executing the expression. AutoSave only applies to main form command bars and can occur for both new and existing data rows.

AutoSave behavior for new rows

When a user selects the command while creating a new row, the app attempts to save the row with the entered data. After the row is saved successfully, the command logic runs, and Self.Selected.Item is set to the newly created row. Your Power Fx logic runs as expected.

If the user hasn’t completed all required columns, the save action fails. However, the command logic will still run. Since the new row wasn't created, Self.Selected.Item is blank. Logic that depends on this property—such as updating columns or creating related rows—won’t function correctly.

To prevent user confusion, consider hiding the command button when a new row is in progress. Use this formula for the Visibility property:

If (Self.Selected.State = 1, false, true)

This approach helps avoid triggering business logic prematurely—for example, when a user has filled out only 5 of 20 fields, and an automation runs before all data is entered.

In certain cases, this behavior can be intentional and useful. For example, a Save and Ship command might create the order and immediately queue it for shipment. This supports a streamlined experience where the user doesn't need to select Save separately.

AutoSave behavior for existing rows

When a user selects the command while editing an existing row, the form attempts to save the changes before running the command. If the save is successful, the command logic runs and Self.Selected.Item reflects the updated row.

If you disable AutoSave, the form won’t save changes before executing the command. In this case, Self.Selected.Item retains the row’s previous state. This can affect any downstream automations triggered by data updates.

How to disable AutoSave

By default, commands that use Power Fx have AutoSave enabled in the component library. To disable it, add JavaScript to the form’s OnSave event. For more information, see Disable AutoSave for a form.