JavaScript

{dialog.object}getDateValue Method

Syntax

var d = {dialog.object}.getDateValue(ControlId);

Arguments

ControlIdstring

The name of the control to get the value and return as a date object.

Returns

dDate

Returns the value of the specified control parsed as a date object.

Description

Get the valuel of a control in the UX Component as a JavaScript Date object.

Discussion

When you use the .getValue() method to retrieve the value of any control, a string is returned, regardless of the control's defined data type. In the case of numeric and logical types, casting the value to the required Javascript type is easy (using the $u.s.toNum() or $u.s.toBool()) functions, but casting to a date value is harder because the data value has to be parsed. The .getDateValue() method can be used to get the value from a control in the UX Component as a JavaScript Date object.

For example:

function setShipDate() {
    var orderDate = {dialog.object}.getDateValue('orderDate');

    var shipDate = orderDate.addTime('week',1);
    {dialog.object}.setValue('shipDate', shipDate.toFormat("MM/dd/yyyy"));
}

The date string in the control is parsed into a date object using the client-side date and time format defined in the UX component.

See Also