* Can't create/update repository field in templated source

For plugin authors to discuss plugin programming
Post Reply
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Can't create/update repository field in templated source

Post by shoshk »

I have no problem creating/updating other types of fields (like TEXT or DATE). But, for some reason, I can't create/update a repository field.

Here's a snippet of code:

Code: Select all

local pSource = pCite.source
local pRepository = SetRepository(pSource, tblFields["RP-Repository"].Value)
local sTag = "~.~RP-Repository"
local ptrItem = fhGetItemPtr(pSource, sTag)
if ptrItem:IsNull() then
	ptrItem = fhCreateItem(sTag, pSource)
end
if ptrItem:IsNotNull() then
	fhSetValueAsLink(ptrItem, pRepository)
end
Where:

pRepository points to the repository record (stepped through in debugger and verified)
pSource points to the source record
sTag is the specification for the repository field (in my case - RP-Repository)

The call to fhGetItemPtr(pSource, sTag) returns NULL, as does the subsequent call to fhCreateItem(sTag, pSource).

What am I doing wrong?
Shosh Kalson
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Can't create/update repository field in templated source

Post by tatewise »

fhGetItemPtr will return null if field does not exist.
fhCreateItem tag must not start with tilde dot.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Can't create/update repository field in templated source

Post by shoshk »

Thank you, thank you!

I missed that.

What would I (and all of us) do without you?
Shosh Kalson
Post Reply