Adding KeyAttributes

I can’t find the correct code for $OnAdd to add additional $KeyAttributes for all notes within a container:

$KeyAttributes=$KeyAttributes+“Learning;Known;NotKnow”

overwrites all existing KeyAttributes. How can I add KeyAttributes?

*(Learning, Known and NotKnow are already defined user-attributes.)

What about this:

$KeyAttributes=($KeyAttributes+“Learning;Known;NotKnown”);

And if that fails, I’m not sure if TB allows for Smart Quotes there. I also assume you meant ‘NotKnown’ not ‘NotKnow’. Perhaps that’s why it failed.

Yes, this works. I missed the parentheses. Thanks, Ralph!

2 Likes

Assuming the curly quotes are due to forum re-formatting of text, when I test:

$KeyAttributes=$KeyAttributes+"Learning;Known;NotKnown"

I get 3 new attributes in the notes KAs. So I wonder if there is some other factor at play in @Dirk’s document.

In action code, adding a string of semi-colon delimited terms to a Set or List type attribute will cause the string to be parsed into items and each of those will be added as a new list item. See more.

$KeyAttributes=$KeyAttributes+“Learning;Known;NotKnow”

This does work, too. Of course, the quotation marks must be straight quotes.

Could it be because his original code misspelled ‘NotKnown’ and there was no User Attribute $NotKnow?

I doubt it. I added a $Learning attribute and note the other two, then used the code to stamp a note with an existing KA. The result:

Untitled%202019-04-12%2017-04-09

The greyed out items in the KAs are attribute names defined in the notes $KeyAttributes list values but which don’t match an existing attribute.

I tried $KeyAttributes=$KeyAttributes+"Learning;Known;NotKnown" again and it works now. Probably I really used incidentally curly braces (wasn’t aware of this).

So thanks again, everybody.
Really appreciate your efforts!

2 Likes