Page 1 of 1

BEWARE MoveNextSpecial skips Citation Metafields

Posted: 23 May 2021 10:54
by tatewise
Beware Plugin Authors:
ptrItem:MoveNextSpecial() should iterate through all fields and records within a record type.
But if a Source Citation has Citation-specific templated Metafields (_FIELD) the iteration skips all the Citation subfields.
e.g.
If %INDI.BIRT.SOUR% has a subfield such as %INDI.BIRT.SOUR._FIELD% it is skipped by ptrItem:MoveNextSpecial() along with any other subfields including generic fields such as %INDI.BIRT.SOUR.NOTE2% and %INDI.BIRT.SOUR.DATA.TEXT%

I will report this problem to Calico Pie ASAP.

It impacts plugins such as Search and Replace and Where Used Record Links and any that use Code Snippet Loop All Items.

The workaround is to replace ptrItem:MoveNextSpecial() with:

Code: Select all

if fhGetTag(ptrItem) == "SOUR" then
	local ptrNext = ptrItem:Clone()
	ptrNext:MoveToFirstChildItem(ptrNext)
	if ptrNext:IsNotNull() then
		ptrItem = ptrNext:Clone()
	else
		ptrItem:MoveNextSpecial()
	end
else
	ptrItem:MoveNextSpecial()
end

Re: BEWARE MoveNextSpecial skips Citation Metafields

Posted: 25 May 2021 10:58
by tatewise
The response from Calico Pie today is:
"Thank you for reporting that. We have confirmed the issue. It will be fixed in the next update, which should be out shortly."