TX Text Control .NET Server

Javascript: ApplicationField.getTypeName Method

Method|Introduced in 28.0

Description

Gets the field's type name. The type name of a Microsoft Word MergeField is MERGEFIELD, for example. If the type name of the field is changed, its parameters must also be changed.

Syntax

<void> ApplicationField.getTypeName(<RequestStringCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the field's type name.

errorCallback

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

Examples

The following example demonstrates ApplicationField.getTypeName in a practical document-editing workflow. It gets the field's type name. The type name of a Microsoft Word MergeField is MERGEFIELD, for example. If the type name of the field is changed, its parameters must also be changed.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const applicationFields = mainText.applicationFields;
    applicationFields.getItem(function(applicationField) {
        if (!applicationField) {
            console.warn("No application field is available at the current input position.");
            return;
        }
    
        applicationField.getTypeName(
            function(result) {
                console.log("get type name result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);