* Getting the pointer to a _PLACE note

Writing and using plugins for Version 5 and above.
Post Reply
avatar
shoshk
Diamond
Posts: 97
Joined: 13 May 2015 16:28
Family Historian: V6.2
Location: Ashkelon, Israel

Getting the pointer to a _PLACE note

Post by shoshk » 11 Oct 2019 12:13

I know it's a stupid question, but I can't find the answer, so...

I have the following code:

pNote = fhGetValueAsLink(pi, '~.NOTE2')

where pi points to a _PLAC record. I've tried several variations on the data reference. All return 'null'. I guess I'm missing a period or something.

Can you help?

Thanks,
Shosh

avatar
shoshk
Diamond
Posts: 97
Joined: 13 May 2015 16:28
Family Historian: V6.2
Location: Ashkelon, Israel

Re: Getting the pointer to a _PLACE note

Post by shoshk » 11 Oct 2019 12:17

OK. Really was a stupid question. :oops:

I forgot that I had to create the note if it didn't exist.

All works now.

Shosh

User avatar
Jane
Site Admin
Posts: 7743
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Getting the pointer to a _PLACE note

Post by Jane » 11 Oct 2019 12:42

Were you meaning strText =fhGetValueAsText(ptr) as NOTE2 is a local note there should be no link to another record.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

avatar
shoshk
Diamond
Posts: 97
Joined: 13 May 2015 16:28
Family Historian: V6.2
Location: Ashkelon, Israel

Re: Getting the pointer to a _PLACE note

Post by shoshk » 11 Oct 2019 12:45

Ok, still having a problem.

pNote = fhGetValueAsLink(pi, '~.NOTE2') always returns null.

So then I
if pNote:IsNull() then
pNote = fhCreateItem('NOTE2', pi)
end
fhSetValueAsText(pNote, sNote)

which creates a new note for the place. Every time I run the plugin. Which is not what I want. Argh!

User avatar
Jane
Site Admin
Posts: 7743
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Getting the pointer to a _PLACE note

Post by Jane » 11 Oct 2019 13:20

As I said you can't get a "link" to the Note as the note2 is local and and not a separate record.

Try the following

Code: Select all

local pNote = fhNewItemPtr()

pNote:MoveTo(pi,'~.NOTE2')

if pNote:IsNull() then
pNote = fhCreateItem('NOTE2', pi)
end

fhSetValueAsText(pNote, sNote)
 
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

avatar
shoshk
Diamond
Posts: 97
Joined: 13 May 2015 16:28
Family Historian: V6.2
Location: Ashkelon, Israel

Re: Getting the pointer to a _PLACE note

Post by shoshk » 11 Oct 2019 13:26

Got it working. The correct syntax is:

pNote = fhGetItemPtr(pi, '~.NOTE2')

Thanks for helping.

Shosh

Post Reply