Import all notes from two or more attachments for one item/article zotero integration

I create a templater to import all notes from two or more pdf attachments in an item with zotero integration. It works in the "data explorer ", but fails in import #1 and reported as follows
1692761039069

It works for those with only one pdf attachments, but not those with two or more pdf attachments.

Short description for the template below

first ceate a variable “newAnnotationsLengthS” as the number of new annotation in all pdf attachments
check if newAnnotationsLengthS > 0, then import annotations

I wonder how I combine those annotations in all pdf attachments to new object?

template demo

## 2. Annotation
{% persist "annotations" %}
{% set newAnnotationsLengthS = 0 %}
{% for attachment in attachments | filterby("path", "endswith", ".pdf")%}
	{% set tmpAnn = attachment.annotations %}
	{% set tmpNewAnn = tmpAnn | filterby("date", "dateafter", lastImportDate) %}
	{% set newAnnotationsLengthS = newAnnotationsLengthS + tmpNewAnn.length %}
{% endfor%}
{% if newAnnotationsLengthS > 0 %}
### Imported: {{importDate | format("YYYY-MM-DD h:mm a")}}
	{% for attachment in attachments | filterby("path", "endswith", ".pdf")%}
		{% set tmpAnn = attachment.annotations %}
		{% set tmpNewAnn = tmpAnn | filterby("date", "dateafter", lastImportDate) %}
		{% for each in tmpNewAnn %}
			{%- if each.annotatedText -%}
- [ ] original text:[{{each.annotatedText}}](zotero://open-pdf/library/items/{{each.attachment.itemKey}}?page={{each.page}}&annotation={{each.id}})
			{%- endif %}
			{%- if each.imageRelativePath -%}
![[{{each.imageRelativePath}}]]
			{%- endif %}
			{%- if each.comment-%}
comment:{{each.comment}} 
			{%- endif %}

		{% endfor%}
	{% endfor%}
{% endif %}
{% endpersist %}

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