Attribute list based on child notes

I’d like to use the names from the children of a note as an attribute list for a prototype. Ideally I’d have a note at the document root with children representing attribute names. E.g., I have a Note called “Clients” its children would be “Company 1, Company 2, etc.” I also have a prototype with a user attribute of “ClientName” which would show a list of clients based on the children of “Clients”. This way I’m using the outline view to keep the client list updated and I could make notes about the client.

I’m sure I’m not explaining this correctly, apologies.

Prototype’s Rule:

$ClientName = collect(children("Clients"), $Name);

N.B. assumption: the $Name ‘Clients’ is unique across the whole document. If not you will need to use the full $Path for that note in the above rule.

Does that help?

1 Like

This is a great plan. I do this a lot.

BTW, I do this a little differently. I have a configuration note that I use to process these types of $Rules and/or $Edicts, that way the Rule/Edict only has to run on one note, and the rest of the notes benefit.

1 Like

:grinning: Thank you both very much; this worked perfectly.

Wanted to ask, with 9.6 , other ways to achieve this?

Wanted to ask, with 9.6 , other ways to achieve this?

An alternative, slightly faster for large documents, is

$Name(children("Clients"))

or

$Path(children("Clients"))

if the name might not be unique, or

$IDString(children("Clients"))

if the path might not be unique.

I think that’s as simple as it could possibly be, but perhaps you have something specific in mind?

Thank you for reply.

If the attribute is a default displayed attribute and not deriving from a prototype , how to apply above ?

Neither of the above involves either prototypes or displayed attributes.

Is the issue that instead of ‘Clients’ in the following code:

$Path(children("Clients"))

you want the collected attribute to be set dynamically, e.g via a variable. If so, how do you intend to set it (i.e. from where is the value read?).

For instance to get a list of the values of the $MyString attribute of all children:

var:string vAttrName = "MyString";
$MyList = collect(children,vAttrName);

Or, if $MyString is a Displayed Attribute of the current note and first listed in the DA table (i.e. 0-th in the list stored in $DisplayedAttributes):

var:string vAttrName = $DisplayedAttributes.at(0);
$MyList = collect(children,vAttrName);

Hi Team,
Travelling from 2 Days(for 1 more day) and hence no reply.

Will trouble you both soon :smiley:

1 Like

HI Mark(s),
I am back from my Travel.

I imagined a note Employees with 4 children
Prashant
Mark A
Mark B
Tim Cook

I have an attribute called “AssignedTo” which is a “set” , Whenever the said attribute is used on a note , I would like it’s dropdown menu to have the the above 4 names and if I were to add a 5th children , it should present the new name as option too.

When I typed this out , I realise my question is different from post, If It helps I can create a new topic.

OK, for the container (rule or edict)::

$AssignedValues = collect(children, $Name)

So if currently the cointainer’s $AssignedTo value is “Prashant;Mark A;Mark B;Tim Cook”, and you added a new child note ‘Oppenheimer’, the result is a value of “Prashant;Mark A;Mark B;Tim Cook;Oppenheimer”.

If you want the suggested values for the $AssignedTo for only this container, that can’t be done as suggested values apply at whole-document scope.

Does that help?

BTW, this is a practice I suse in my resource folder, e.g. “People Folder” or “Company Folder”. I’ll put in the $Edict of any of the note containers like this the collect code Mark suggests above. That way the Attribute, e.g., “Owner,” “Regulation,”, “Company,”, etc., is pre-populated with all the available options.

Wohoo , This works !!

Need a deep dive into your best practises , or have you already done such a video?

Wow, that’s a tall order. :slight_smile: I have many, including 10s if not 100s of stamps, functions, and templates. It all depends on the context and project. I’m working on finishing up my doctorate. Once that is done, I plan to offer courses. In the meantime, I go into “really deep” personal best practices through my Patreon channel, Michael Becker | creating training materials and thought-leadership | Patreon. Time permitting, I help when I can through the forum.