Meaning of `id` in card templates

In the CardTemplate impl inside rslib/src/notetye/template.rs there’s an id that gets initialized with a number. what is its significance? Apologies if this is made obvious somewhere else in code, i’m not very familiar with Anki’s objects and their properties.

It was added to uniquely identify templates to support the Merge Notetypes feature: Merging Notetypes on Import by RumovZ · Pull Request #2612 · ankitects/anki · GitHub

3 Likes

I was creating fields using CrowdAnki (copy pasting the field part and editing ord and id so that they’re unique), and noticed there is an id for fields, card templates and notetypes.
On exporting, does it rerandomize the ids, or does that occur on imports? And what would happen if there are two card templates having the same id?

Not familiar with the exact process, but I think the IDs are only used to make merging templates/fields less error-prone. Anki simply falls back to name matching in case there are no IDs (old note types).

Looks like nothing is done in that case (except adjusting the ordinal): Merging Notetypes on Import by RumovZ · Pull Request #2612 · ankitects/anki · GitHub

1 Like