Hi Everyone,
it's been a while since I coded in NCP after having implemented all features I needed. But there is always something else coming my way :-)
Requirement was to automatically inherit the icon from the parent note when creating a new child note.
The code snippet is
--Inherit Icon from Parent
nDocID = Nc_Doc_ID_GetCur()
-- check whether this routine should run at all
-- find custom property by name; store its custom property index number as variable nPropIdx
nPropIdx = Nc_Note_CustProp_FindByName(nDocID, "", "$ActionAfterCreate")
if nPropIdx == -1 then
return
end
strDoAction = Nc_Note_CustProp_GetValueByIdx(nDocID, "", nPropIdx)
if strDoAction == "1" then
strNoteID = Nc_Note_ID_GetCur(nDocID)
strParentNote = Nc_Note_Parent_GetID(nDocID, strNoteID)
if strParentNote == "" then
return
end
nIconType, strIconValue = Nc_Note_Icon_GetValues(nDocID, strParentNote)
Nc_Note_Icon_SetValues(nDocID, strNoteID, nIconType, strIconValue)
-- append the custom properties I need
Nc_Note_CustProp_Append(nDocID, strNoteID, "Entfernung", "")
Nc_Note_CustProp_Append(nDocID, strNoteID, "Dauer Std", "")
end
this script is then assigned to the event "after inserting a note". In order to control on which files the script runs I use a global custom property "$ActionAfterCreate" which needs to have a value of "1"
just posting it in case one finds it handy
best regards
Raimund