TX Text Control .NET Server

Javascript: ApplicationFieldCollection.remove Method

Method|Introduced in 28.0

Description

Removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

Syntax

<void> ApplicationFieldCollection.remove(<ApplicationField> applicationField, <Boolean> keepText, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
applicationField

Specifies the field to remove.

keepText

If this parameter is set to true, the field is removed without deleting its visible text. Otherwise, the field's text is also deleted.

callback

Optional. Receives true, if the field could be removed. Otherwise, it is false.

errorCallback

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

Examples

The following example demonstrates ApplicationFieldCollection.remove in a practical document-editing workflow. It removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

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

function remove(applicationField) {
    TXTextControl.textParts.getMainText(function(mainText) {
        const applicationFields = mainText.applicationFields;
        applicationFields.remove(
            applicationField,
            true,
            function(result) {
                if (result) {
                    console.log("remove is available.");
                } else {
                    console.warn("remove is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}