Reported to CP, and received a detailed explanation of what we are seeing
.
There is a subtle difference between
Notes and the new
Research Notes that we had not spotted. For
Note Records, you have to create the new Record and its TEXT field separately, as per the code above. For the new
Research Note Record, the TEXT field is created automatically when the record is created.
In the code above,
p2 has a value of nil after the call to
fhCreateItem, as the TEXT field exists already, and as only one is permitted, the function call fails and returns a nil value. This can be confirmed in the debugger.
The solution is to either call
fhCreateItem with a value of true for the optional
ReuseEmpties third parameter that defaults to false, or to use the existing newly-created empty TEXT field rather that try to create a new one. Corrected code is show below, and both versions work as intended:
Code: Select all
-- option 1
p1 = fhCreateItem('_RNOT')
p2 = fhCreateItem('TEXT', p1, true)
fhSetValueAsText(p2, 'This is my text')
print(fhGetValueAsText(p2))
-- option 2
p1 = fhCreateItem('_RNOT')
p2 = fhNewItemPtr()
p2:MoveTo(p1, "~.TEXT")
fhSetValueAsText(p2, 'This is my text')
print(fhGetValueAsText(p2))
Now we know
Research Notes can be populated in code, I will convert the development plugin to
Import RootsMagic ToDo List to work with Research Notes for FH7 as intended originally as they would be the preferred option. Rather than exclude FH6 users completely, I will set it up to import as standard
Notes in FH6. Standard
Notes need a bit more work to display optimally and keep separate from all the other
Note Records that a typical Project has, but they are better than nothing for the sake of a few extra lines of code.