Copy Child Branch Fields code snippet for FH V7
Posted: 14 Jan 2021 14:35
The KB code snippet Copy Child Branch Fields fails for FH V7 scenarios involving rich text Notes and source citation metafields.
The function CopyBranch(...) needs amending as below:
The function CopyBranch(...) needs amending as below:
Code: Select all
function CopyBranch(ptrSource,ptrTarget)
local strTag = fhGetTag(ptrSource)
if strTag == "_FMT" then return end -- Skip rich text format code
if strTag == "_FIELD" then -- Substitute metafield shortcut
strTag = fhGetMetafieldShortcut(ptrSource)
end
local ptrNew = fhCreateItem(strTag,ptrTarget,true)
if ptrNew:IsNull() then return end -- Escape if item not created
fhSetValue_Copy(ptrNew,ptrSource)
CopyChildren(ptrSource,ptrNew)
end -- function CopyBranch