* BEWARE MoveNextSpecial skips Citation Metafields

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

BEWARE MoveNextSpecial skips Citation Metafields

Post by tatewise » 23 May 2021 10:54

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
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: BEWARE MoveNextSpecial skips Citation Metafields

Post by tatewise » 25 May 2021 10:58

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."
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply