Automtically Inherit Icon from Parent and set custom Properties

18 views
Skip to first unread message

info.sim...@googlemail.com

unread,
Feb 20, 2022, 11:37:10 AM2/20/22
to Notecase Pro
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

Miroslav Rajcic

unread,
Feb 24, 2022, 8:35:32 AM2/24/22
to Notecase Pro
Hi Raimund,

thanks for sharing, I can see that this can be useful feature.

Note that this reminds me of existing "Template" flag note property.
When the note is declared template, and you add a child note under it, the child will inherit parent's icon, but also its note contents.
This is useful if you need some monthly reports, i.e. each child note gets the default report template, that only needs to have some empty parts filled in (i.e. numbers for the current month).

Best regards.
  Miro

From: 'info.sim...@googlemail.com' via Notecase Pro <noteca...@googlegroups.com>
Sent: Sunday, February 20, 2022 5:37 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Automtically Inherit Icon from Parent and set custom Properties
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/e9b17b9e-7749-4b64-95d6-30fb6ab704a4n%40googlegroups.com.

Paul Merrell

unread,
Feb 24, 2022, 10:01:32 AM2/24/22
to Notecase Pro
On Thu, Feb 24, 2022 at 5:35 AM Miroslav Rajcic <mra...@hotmail.com> wrote:
Hi Raimund,

thanks for sharing, I can see that this can be useful feature.

Note that this reminds me of existing "Template" flag note property.
When the note is declared template, and you add a child note under it, the child will inherit parent's icon, but also its note contents.

More than that. From the Help file: 

"When you mark a note as a template, each time you create its descendant note, the new note will be a duplicate of its parent. The new note inherits the original note's text, images, links, formatting, attachments, and note properties including syntax highlighting selections and note tags copied from its parent."

The template note feature is controlled from the Note Properties dialog.  

--
[Notice not included in the above original message:  The U.S. National Security Agency neither confirms nor denies that it intercepted this message.]
                                                ¯\_(ツ)_/¯

Miroslav Rajcic

unread,
Feb 24, 2022, 11:52:29 AM2/24/22
to Notecase Pro
Thanks Paul,

I guess the program accumulated a lot of useful features over the years, it's hard to remember precise details without looking into help file.

Regards,
 Miro


From: noteca...@googlegroups.com <noteca...@googlegroups.com> on behalf of Paul Merrell <mar...@gmail.com>
Sent: Thursday, February 24, 2022 4:01 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Automtically Inherit Icon from Parent and set custom Properties
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.

info.sim...@googlemail.com

unread,
Mar 2, 2022, 10:02:40 AM3/2/22
to Notecase Pro
Hi Miro, Paul,

I used the template feature in the past but it doesn't support custom properties as far as I remember and the code snippet works better for me. Even when you cut and paste notes within the file.

Also NCP is the perfect solution for many of my needs the extensibility with Lua makes it a no brainer for everthing I want to document. Actually with my extensions I turned it in a very powerful CRM (more or less ;-) )

So please keep maintaining it ;-)

Have a great time

Raimund

Miroslav Rajcic

unread,
Mar 2, 2022, 12:25:40 PM3/2/22
to Notecase Pro
Thanks Raimund,

it's quite nice to see you can tweak the program to your precise needs.

Regards,
  Miro

Sent: Wednesday, March 2, 2022 4:02 PM
Reply all
Reply to author
Forward
0 new messages