# How to fill first field in a newly created note - with some string

**URL:** <https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178>\
**Category:** Add-ons\
**Created:** [August 13, 2024, 6:39pm UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178 "2024-08-13T18:39:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wojckr](https://avatars.discourse-cdn.com/v4/letter/w/3da27b/32.png) [@wojckr](https://forums.ankiweb.net/u/wojckr)\
**Post date:** [August 13, 2024, 6:39pm UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178/1 "2024-08-13T18:39:22Z")

</div>

Hi

I tried few solutions with ChatGPT, however it doesn’t work.

What add-on I would like to have? Right after choosing “Add” i would like to have some string in the first field, added there automatically. Also, during editing any note, if the first fild is empty, I want to put there that string. How to do that? What approche to have?

Thanks for any replies

---

<div class="post-metadata">

**Author:** ![ferophila](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/ferophila/32/10566_2.png) [@ferophila](https://forums.ankiweb.net/u/ferophila)\
**Post date:** [August 13, 2024, 7:26pm UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178/2 "2024-08-13T19:26:25Z")

</div>

I use Keyboard Maestro ([https://www.keyboardmaestro.com](https://www.keyboardmaestro.com)) to add certain cards and fill fields. It is much more flexible than adapting an add-on.

---

<div class="post-metadata">

**Author:** ![eroscard](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/eroscard/32/22632_2.png) [@eroscard](https://forums.ankiweb.net/u/eroscard)\
**Post date:** [August 13, 2024, 7:51pm UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178/3 "2024-08-13T19:51:55Z")

</div>

on the edit card, you click on cards, in front model, type the string, put the field name {{Front}} below it and save

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [August 13, 2024, 8:45pm UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178/4 "2024-08-13T20:45:07Z")

</div>

Have you tried Sticky Fields (built-in to Anki)? [Adding/Editing - Anki Manual](https://docs.ankiweb.net/editing.html#editing-features)

---

<div class="post-metadata">

**Author:** ![wojckr](https://avatars.discourse-cdn.com/v4/letter/w/3da27b/32.png) [@wojckr](https://forums.ankiweb.net/u/wojckr)\
**Post date:** [August 14, 2024, 10:48am UTC](https://forums.ankiweb.net/t/how-to-fill-first-field-in-a-newly-created-note-with-some-string/48178/5 "2024-08-14T10:48:36Z")

</div>

Hi Danika, I didn’t try, however thank you for telling me that, because I was not aware of this functionality. In my first post I forgot to write that I would need every time different string returned by my function.

I the meanwhile a preliminary solution has been found. Here it is:

```auto
from aqt import editor, gui_hooks
import random

def update_field(editor):
    #print('Hello world!')

    note = editor.note
    note_type = editor.note.note_type()

    if 'field_name' not in note:
        print('Field not found')
        return
    
    if note['field_name']:
        print(f'Field is not empty')
        return
    
    value_to_set = random.randint(0, 100)
    note['field_name'] = f'{value_to_set}'
    
    editor.loadNote()

gui_hooks.editor_did_load_note.append(update_field)

```
