How to update annotations from Zotero without changing the old properties and the note I wrote above?

Hi,
I am using a template (copy from another researcher and I modified for several times) to extract highlights and metadata from the Zotero integration plugin to the Obsidian MD file. It works for the initial exporting, but when I make new annotations, it also updates the new highlight but removes all the notes I wrote.

Can I ‘only’ update the new highlights? Following is part of my template,

---
cssclasses: research-note
tags: {% if allTags %}{{allTags}}{% endif %}
citekey: {{citekey}}
---

## Summary

## Annotation

{% persist "annotations" %}
{% if annotations.length > 0 %}
### Imported on {{importDate | format("YYYY-MM-DD h:mm a")}}
{%- for annotation in annotations %}
{% if annotation.color !== "#ffd400" %}
>[!quote{% if annotation.color %}|{{annotation.color}}{% endif %}] {{calloutHeader(annotation.color)}}
>{%- endif -%}{% if annotation.imageRelativePath %}
![[{{annotation.imageRelativePath}}]] {% endif %}{% if annotation.annotatedText %}
{{annotation.annotatedText}} [(p. {{annotation.pageLabel}})](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.pageLabel}}&annotation={{[annotation.id](https://annotation.id/)}}){%- endif %}{%- if annotation.comment%}
%%{{annotation.comment}}%%{%- endif %}{%- endfor %}{% endif %} {% endpersist %} 

The workflow I have,

  1. Extracting annotation and metadata from Zotero to Obsidian
  2. Write a summary or the key ideas in the Summary part
  3. Go back to Zotero and make new highlights
  4. Exporting the new annotations
  5. Read my research note again … (loop starts from step 2 to step 4)

I think the bug is in step 4 since it erases all the summaries in step 2 when I export the new annotation.

What I’m trying to do

  1. Create two notes, one is only for annotation and the other is for summary. But I need to link them every single time when I update the annotation and I need to open the graphic view to see the backlink all the time.

  2. I think I need to modify my template again (?)

Things I have tried

I have tried to use different functionalities from the template or templater, like only extracting the bottom part into a new template and then using the templater to ‘update’ the new annotation. But I don’t think I understand what am I doing but just try-and-error.

There aren’t any timestamps associated with the annotations are there? If that had been the case, you could possible build some template to only pick the newest annotations.

Then your workflow would consist of an initial export with modifications in obsidian, followed up by incremental annotation addition and modification.

Another more heavy tool dependent approach would be to import the annotations twice; one for for modification and day-to-day use, and one as a marker of last import. Then on the new import you could create a patch showing which changes was made either in obsidian or by the new import, and then try applying this patch to the day-to-day variant. This would require some tool setup, and is a little heavy on requiring technical knowledge on patching/fiddling about.

1 Like

Persistent notes

First, you need a persist for your note section, like the one you have around your annotation section. However, this persist section should only be created once. Therefore, it should look like this:

{% persist "notes" -%}
{%- if isFirstImport %}

## Summary

{% endif %}{% endpersist %}

Without isFirstImport , a new “notes” section will be added every time you update.

Basically, {% persist "notes" %} in the template becomes %% begin notes %% in the output. This marks the start of a section that will not be overwritten. Similarly, {% endpersist %} becomes %% end notes %% , which signifies where the persistent section ends. “notes” in this example is just a name, it doesn’t connect to any data or anything like that. So you can name your persistent sections whatever you want.


Persistent properties

Unfortunately, Zotero Integration’s templating can’t persist the properties. However, a workaround is to use Dataview inline fields for the metadata that you need to persist across updates. This could be metadata like “status”. That’s what I do in my template.

I put the dataview fields into the notes persistent section above, under a heading I named “Processing”, like so:

## Processing

- **Status**:: new
- **Connections**::
- **Projects**::

Thank you very much! It exactly solves my problem! Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.