> ## Documentation Index
> Fetch the complete documentation index at: https://developer.suki.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Write Dictation Text to an EHR Field

> Use DictationClient onSubmit to write final dictation text into an EHR chart field

**Problem:** Dictation records, but the EHR chart field does not update on submit.

**Solution:** Pass `onSubmit` to `DictationClient.show` (or `<Dictation />`) and write `text` into the field for `fieldId`.

<Note>
  This cookbook assumes you already have your Partner ID, Partner Token, and the other prerequisites for the Dictation SDK.
</Note>

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    import { SukiAuthManager } from "@suki-sdk/core";
    import { DictationClient } from "@suki-sdk/dictation";

    const authManager = new SukiAuthManager({
      partnerId: "YOUR_PARTNER_ID",
      partnerToken: "YOUR_PARTNER_TOKEN",
      environment: "staging",
      loginOnInitialize: true,
      providerId: "1234567890",
      providerName: "Jane Doe",
      providerOrgId: "1234",
    });

    const dictationClient = new DictationClient({ authManager });

    await dictationClient.show({
      mode: "in-field",
      fieldId: "clinical-notes",
      rootElement: document.getElementById("clinical-notes-field-root-element-id"),
      initialText: "",
      onSubmit: ({ fieldId, text }) => {
        const el = document.getElementById(fieldId);
        if (el) el.value = text;
      },
      onCancel: ({ fieldId }) => {
        console.log("Cancelled", fieldId);
      },
    });
    ```
  </Tab>

  <Tab title="React">
    ```jsx theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    import { useEffect, useMemo, useRef, useState } from "react";
    import { SukiAuthManager } from "@suki-sdk/core";
    import { DictationClient } from "@suki-sdk/dictation";
    import { DictationProvider, Dictation } from "@suki-sdk/dictation-react";

    export function NotesWithDictation() {
      const rootRef = useRef(null);
      const [rootElement, setRootElement] = useState(null);
      const [notes, setNotes] = useState("");

      const client = useMemo(() => {
        const authManager = new SukiAuthManager({
          partnerId: "YOUR_PARTNER_ID",
          partnerToken: "YOUR_PARTNER_TOKEN",
          environment: "staging",
          loginOnInitialize: true,
          providerId: "1234567890",
          providerName: "Jane Doe",
          providerOrgId: "1234",
        });
        return new DictationClient({ authManager });
      }, []);

      useEffect(() => {
        setRootElement(rootRef.current);
      }, []);

      return (
        <DictationProvider client={client}>
          <textarea
            id="clinical-notes"
            value={notes}
            onChange={(e) => setNotes(e.target.value)}
          />
          <div ref={rootRef} id="dictation-root" />
          {rootElement ? (
            <Dictation
              mode="in-field"
              fieldId="clinical-notes"
              rootElement={rootElement}
              initialText={notes}
              onSubmit={({ text }) => {
                setNotes(text);
              }}
              onCancel={({ fieldId }) => {
                console.log("Cancelled", fieldId);
              }}
            />
          ) : null}
        </DictationProvider>
      );
    }
    ```
  </Tab>
</Tabs>

## Common mistakes

* `fieldId` must match the input you update. `rootElement` must exist before `show`.
* Set `loginOnInitialize: true`, or call `login()` before `show`.

## Other cookbooks

<div className="cookbook-hub-wrap">
  <div className="hp-io-method-grid tut-hub-card-grid" data-cookbook-related-grid>
    <a className="hp-io-method-card tut-hub-method-card" href="/documentation/cookbooks/bearer-provider-id-on-login">
      <div className="tut-hub-card-media tut-hub-card-media--blue" aria-hidden="true" />

      <div className="hp-io-method-card-body">
        <div className="tut-hub-card-badges">
          <span className="hp-wn-badge hp-wn-badge-new">Authentication</span>
          <span className="hp-wn-badge cookbook-hub-badge-surface cookbook-hub-badge-surface--api">API</span>
        </div>

        <h3 className="hp-io-method-card-title">Add provider\_id to Bearer Login</h3>

        <p className="hp-io-method-card-desc cookbook-hub-card-desc">
          Send provider\_id on Bearer login.
        </p>

        <div className="hp-io-method-card-meta tut-hub-card-foot" aria-label="5 min">
          <div className="tut-hub-card-foot-meta">
            <span className="hp-io-method-card-meta-time">5 min</span>
          </div>
        </div>
      </div>
    </a>
  </div>
</div>
