* Creating a metafield

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
avatar
JoopvB
Superstar
Posts: 328
Joined: 02 May 2015 14:32
Family Historian: V7

Creating a metafield

Post by JoopvB » 09 Mar 2021 20:23

I am experiencing a serious case of code blindness.

I have a piece of code and am trying to add a metafield to an existing source like this (p is the pointer to the source):

px = fhGetItemPtr(p,'SOUR.~NM-PERSOON') -- works as expected
xx = fhGetValueAsText(px) -- also ok
pz = fhCreateItem('SOUR.~NM-PERSOON_2', p) -- (null) Why?
bOk = fhSetValueAsText(pz, xx) -- false

What am I missing?

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

Re: Creating a metafield

Post by tatewise » 09 Mar 2021 20:36

Should be:
pz = fhCreateItem('~NM-PERSOON_2', p)

p is already pointing to SOUR and the fhCreateItem function needs the tag/shortcut of the child item to create.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 328
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Creating a metafield

Post by JoopvB » 09 Mar 2021 20:40

Thanks Mike!

Post Reply