# Javascript: ApplicationField.setTypeName Method

> Sets 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.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: ApplicationField.setTypeName Method
- **514 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfield/settypename-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfield/settypename-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfield/settypename-method/llms-full.txt

---

### Description

Sets 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

```javascript
<void> ApplicationField.setTypeName(<string> typeName, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| typeName | The type name. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `ApplicationField.setTypeName` in a practical document-editing workflow. It sets 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.

```javascript
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.setTypeName(
            "MERGEFIELD",
            function() {
                console.log("set type name completed.");
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: ApplicationField.setParameters Method](https://docs.textcontrol.com/ds-server/reference/javascript/applicationfield/setparameters-method/llms-full.txt)
- **Next:** [ApplicationFieldCollection Object](https://docs.textcontrol.com/ds-server/reference/javascript/applicationfieldcollection/llms-full.txt)
