Page 1 of 1

Creating a metafield

Posted: 09 Mar 2021 20:23
by JoopvB
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?

Re: Creating a metafield

Posted: 09 Mar 2021 20:36
by tatewise
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.

Re: Creating a metafield

Posted: 09 Mar 2021 20:40
by JoopvB
Thanks Mike!