TX Text Control .NET Server

Javascript: ApplicationField.getParameters Method

Method|Introduced in 28.0

Description

Gets the field' parameters. The order and format of the strings depend on the field's format. For example a Microsoft Word MergeField has the following format: MERGEFIELD FieldName [switches]. In this case the first string of the array is the FieldName and the following strings are possible switches. The string MERGEFIELD is the type name of the field and can be obtained through getTypeName. If a field has no parameters, this array is null.

Syntax

<void> ApplicationField.getParameters(<RequestStringsCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the parameters as a string array.

errorCallback

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

Examples

The following example demonstrates ApplicationField.getParameters in a practical document-editing workflow. It gets the field' parameters. The order and format of the strings depend on the field's format. For example a Microsoft Word MergeField has the following format: MERGEFIELD FieldName [switches]. In this case the first string of the array is the FieldName and the following strings are possible switches. The string MERGEFIELD is the type name of the field and can be obtained through getTypeName. If a field has no parameters, this array is null.

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.getParameters(
            function(result) {
                console.log("get parameters result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);