obsidian-zotero-integration icon indicating copy to clipboard operation
obsidian-zotero-integration copied to clipboard

the lastExportDate is always 1/1/1970, leading to wrong extraction of newly added annotation

Open Youngerkind opened this issue 1 year ago • 2 comments

I have two template files borrowing from the internet. One of them is for extracting newly added annotations, which means that only those, whose date are newer than the literature's lastExportDate, will be exported.

However, every literature's lastExportDate in the Data Explorer is "1/1/1970 8:00:00 AM" at present. Thus, the script will export all annotations now.

(2024/09/09) FYI, I put the template file below.

{% set annots = annotations | filterby("date", "dateafter", lastImportDate) -%}
{% if annots.length > 0 %}
# Background
{% for an in annots -%}
{% if an.colorCategory == 'Yellow' -%}
{% if an.annotatedText -%}
"{{an.annotatedText}}" ([@{{citekey}}](zotero://open-pdf/library/items/{{an.attachment.itemKey}}?page={{an.page}}&annotation={{an.id}}))
{% endif %}
{%- if an.imageBaseName %}![[{{an.imageBaseName}}]]([@{{citekey}}](zotero://open-pdf/library/items/{{an.attachment.itemKey}}?page={{an.page}}&annotation={{an.id}}))
{% endif -%}
{{an.comment}}
{% endif %}
{%- endfor -%}

Youngerkind avatar Jul 10 '24 01:07 Youngerkind

I thought when a note is being exported, the Zotero Integration will write a date to the file's matadata in Zotero. But I not familiar with javascript, I don't know how to change the code.

I try to downgrade my Zotero7 to Zotero6, but it doesn't work

zeroYlin avatar Aug 24 '24 11:08 zeroYlin

That won't affect the template below, it can correctly import the note which being added later. I am not sure what exactly the lastImportDate is, it seems that it is independent from the lastExportDate in Data Explorer.

{% persist "annotations" %}
{% set newAnnotations = annotations | filterby("date", "dateafter", lastImportDate) %}
{% if newAnnotations.length > 0 %}

### Imported: {{importDate | format("YYYY-MM-DD h:mm a")}}

{% for a in newAnnotations %}
> {{a.annotatedText}}
{% endfor %}

{% endif %}
{% endpersist %}

zeroYlin avatar Sep 05 '24 08:09 zeroYlin