DS Server

Javascript: FormFieldCollection.addDateFormField Method

Method|Introduced in 28.0

Description

Adds a new DateFormField.

Syntax

<void> FormFieldCollection.addDateFormField(<Number> emptyWidth, [<RequestDateFormFieldCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
emptyWidth

Specifies the horizontal extension, in twips, of the DateFormField, when there is no date set. When this parameter is set to 0, a default value is used.

callback

Optional. Receives the added DateFormField.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates FormFieldCollection.addDateFormField in a practical document-editing workflow. It adds a new DateFormField.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const formFields = mainText.formFields;
    formFields.addDateFormField(
        1440,
        function(dateFormField) {
            if (!dateFormField) {
                console.warn("No date form field was returned.");
                return;
            }
            
            console.log("add date form field result:", dateFormField);
        },
        onTxError
    );
}, onTxError);