## Hl7Field.setComponent() method [​](/content/docs/sdk/core.hl7field.setcomponent#hl7fieldsetcomponent-method/index.html)

Sets a component value at the specified indices. Note that the indices are 1-based, not 0-based.

**Signature:**

```typescript
setComponent(component: number, value: string, subcomponent?: number, repetition?: number): boolean;
```

## Parameters [​](/content/docs/sdk/core.hl7field.setcomponent#parameters/index.html)

| Parameter  | Type    | Description                               |
|------------|---------|-------------------------------------------|
| component  | number  | The component index                       |
| value      | string  | The new component value                   |
| subcomponent | number | _(Optional)_ Optional subcomponent index  |
| repetition | number  | _(Optional)_ Optional repetition index     |

**Returns:**

boolean

true if the component was set, false otherwise

- [Hl7Field.setComponent() method](/content/docs/sdk/core.hl7field.setcomponent#hl7fieldsetcomponent-method/index.html)
- [Parameters](/content/docs/sdk/core.hl7field.setcomponent#parameters/index.html)
