## Hl7Segment.setField() method

Sets a field at the specified index. If that index does not exist, it will be added. Note that the index is 1-based, not 0-based.

**Signature:**

```typescript
setField(index: number, field: Hl7Field | string): boolean;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| index | number | The field index |
| field | [Hl7Field](/content/docs/sdk/core.hl7field) \| string | The new field value |

**Returns:**

boolean

true if the field was set, false otherwise

- [Hl7Segment.setField() method](/content/docs/sdk/core.hl7segment.setfield#hl7segmentsetfield-method/index.html)
- [Parameters](/content/docs/sdk/core.hl7segment.setfield#parameters/index.html)
