← All entries

Setting default values for date fields on Power Pages

Praxisis D365 Wiki · Public reference · Client-specific details redacted

Source: Claude.ai chat (original: setting-default-date-field-values-on-power-pages__ec4c3109.md) Added: 2026-10-02

Summary

  • Three routes, in "least code first" order: (1) Basic Form Metadata → Prepopulate Field (no-code, built-in). (2) Custom JavaScript (for relative dates / conditional defaults / "today + 30"). (3) Server-side plugin or Power Automate (authoritative, runs regardless of client behaviour).
  • Dataverse column default values and business rules do NOT run in Power Pages — only in model-driven apps. For a default that must hold, write it server-side.
  • Basic Form Metadata section choices: Prepopulate Field writes the value at form load (user can override) · Set Value On Save writes server-side (overrides whatever user entered — equivalent of a locked field).

Key takeaways

  • Picker API over .val(): date fields render with Bootstrap DateTimePicker, attached to the next sibling of the field input. Go through .data("DateTimePicker").date(...) — more reliable than .val() because a date field is actually two elements: #new_startdate (posted) and #new_startdate_datepicker_description (visible).
  • FormMode.New guard: check $fld.val() === "" before setting — otherwise the Edit form gets its existing value clobbered.
  • Metadata conflict rule: if two Attribute-type metadata records exist for the same attribute with conflicting actions, the one created first wins — silently. Use one record with both Prepopulate + Set Value On Save sections populated.
  • Read-only trap: a disabled input isn't POSTed. Use readonly instead, or the Prepopulate value will not persist. Combine Prepopulate (shows value) + Set Value On Save (writes value) + readonly attribute to lock a field correctly.
  • Timezone trap: User Local behaviour columns convert via portal contact timezone — classic off-by-one-day bug. For calendar-only dates, set the column's behaviour to Date Only in Dataverse and use moment().startOf("day").

Learnings / how to apply

  • Standardize the Prepopulate + Set Value On Save + readonly triple in a reusable Portal Field Patterns doc.
  • "Date Only vs User Local" belongs in the Praxisis Sustain Operating Model's data-modelling checklist — it prevents a recurring class of production incident.
  • If a field doesn't need to be visible, use only Set Value On Save and remove the field from the form — simpler, F12-proof, no JS required.

Need this applied to your own tenant?

Praxisis Sustain Self-Serve builds a private AI Wiki trained on your documents and tickets, with free Tier-2 support when the AI cannot answer. Book a 30-min overview.