Skip to main content
Version: 1.x

Function: setDatePickerValue()

setDatePickerValue(page, controlId, date, options?): Promise<void>

Ai

Sets a date value on a sap.m.DatePicker control.

Parameters​

page​

DatePage

Playwright Page (or compatible subset).

controlId​

string

The ID of the DatePicker control.

date​

DateInput

The date to set (Date object or ISO string).

options?​

DateOptions

Optional date operation settings.

Returns​

Promise<void>

Capability​

ui5.date.setDatePicker

Intent​

Set a date on a UI5 DatePicker control with automatic format conversion.

Guarantee​

On success, the control's value is set and fireChange() has been called.

Prerequisite​

The control must be a sap.m.DatePicker and must exist in the UI5 view.

Recipe​

Date picker interaction:

  1. await setDatePickerValue(page, controlId, date)
  2. Optionally validate: await setAndValidateDate(page, controlId, date)
  3. Read back: const val = await getDatePickerValue(page, controlId)

Ai Context​

Reads the control's valueFormat, converts the input to match, then calls setValue() + fireChange(). This prevents the silent wrong-format bug where the date shows as invalid in the UI.

Sap Module​

sap.m.DatePicker — setValue(), getValueFormat(), fireChange()

Business Context​

Set dates on SAP form fields (posting date, delivery date, etc.).

Remarks​

Reads the control's valueFormat, converts the input accordingly, then calls setValue() and fireChange({valid: true}) in a single evaluate script.

Example​

await setDatePickerValue(page, 'datePicker1', new Date(2024, 0, 15));
await setDatePickerValue(page, 'datePicker1', '2024-01-15');