I am new to plugin writing and hope someone can help me.
Trying to make a plugin where I correct my data. Example here is to set the nickname field to the same as the usedname field. I am able to get the current values in the fields - but I do not understand how to update the same fields.
Have tried the following code:
Code: Select all
pi:MoveToFirstRecord('INDI') -- set the first to point to the first Source record
while not pi:IsNull() do
-- For each Person
-- Retrieving info to variables
strRefn = fhGetItemText(pi,'INDI.REFN')
strName = fhGetItemText(pi,'INDI.NAME')
strNameUsed = fhGetItemText(pi,'INDI.NAME._USED')
strNameNick = fhGetItemText(pi,'INDI.NAME.NICK')
-- Example person for testing
if (strRefn == '52') then
-- output fields (THIS WORKS FINE)
print(strRefn, strName, ' Used: ',strNameUsed, ' Nick: ',strNameNick)
-- Updating nickname with used name (DO NOT WORK)
piNameNick = fhCreateItem('NAME.NICK', pi) -- create a NAME field within this record, and set ptr to it
fhSetValueAsText(piNameNick, strNameUsed) -- set value of the name using passed in parameter
end
pi:MoveNext()
end
Best regards,
Øivind