Hi there. I have what is probably a silly question. I have an attribute $keywords and I want to copy the value in $Keywords, for every note, to the attribute $Tags. How would I go about doing this?
$Tags = values("Keywords");
See the values() operator.
I see, but this operation will all keywords used across all notes into the $Tags for a note. What I’m trying to do is for each note move the current entries in that notes keywords attribute into that notes tags attribute. I want to do this across the entire file. So, when I get the operator correct my thought is that I could use a Rule to accomplish this, no?
First: attribute names are case sensitive. $keywords and $Keywords are different attributes.
The way to do this is to make an agent.
Since true is always true, the agent will find every note in the document.
This will replace the value of $Tags with the value of $keywords for each note found by the agent.
Sorry, your opening question could be read several different ways and I picked the wrong one. no matter, I think the post above this one has the answer you need.
Thanks. Sorry if I’m not being clear with my question. Let me try one more attempt.
Let’s say I have 3 notes.
Note 1 has $Keywords: Apple;Juice;Orange
Note 2 has $Keywords: Shirt;Pants;Shoes
Note 2 has $Keywords:
I want to run an rule that moves the content in $Keywords to $Tags for each note so at the end of the process I have:
Note 1 has $Tags: Apple;Juice;Orange
Note 2 has $Tags: Shirt;Pants;Shoes
Note 2 has $Tags:
Later, once it is done I’ll delete the $Keywords attribute and stop the rule.
OK, use this agent query to find all notes with values(s) for $Keywords:
If that’s confusing, a more verbose form would be:
$Keywords != ""
So, now your agent has an alias for every note with $Keywords. Set your agent action to:
$Tags = $Tags + $Keywords;
The latter ensure that if a note has $Tags values that aren’t also in $Keywords, the latter are added to the list and don’t replace existing non-matching Tags. As for matching values, as explained above, $Tags is a Set-type so only one copy of each discrete value (by case-sensitive match) is stored in $Tags.
Eureka! Your customer service and dedication to the community is laudable. Thank you. Worked perfectly. I’ve learned more about Tinderbox in the last week since the community call than I have in years. So grateful to the community.
Just what I was looking for!
In my case, I would like to set the user-defined $Source attribute equal to the $Title attribute for that note. Same method?
HI @kderbyshire. Yes, that would be the same method. I actually do something very similar.
In $OnAdd you could say
$Source=$Source+$Name. I use this method to automatically add citations to notes about articles I’m reviewing. I create a parent note, then as I add notes to this note; they pickup the notes attributes. I use, to be precise:
Prototype="pNote"; $Citation=$Citation(parent); $Source=$ID(parent); $SourceName=$Name(parent); $PublicationYear=$PublicationYear(parent); $StartDate=$StartDate(parent); $Bibliography=$Bibliography(parent);
Here is an example:
All you have to do is double click and add the note and it picks up the parent’s name or any other attribute.
Also, not sure if you’re aware of this, but you can use this same method to pass data along links.
For example in the Inspector on the Link Action you could say:
$Source(destination)=$Source(destination)+$Name(source). This will add the linkFrom note’s $Name to the linkTo note’s $Source.
Mod-edit above to format code (e.g. avoiding quote-type co-ercion). Line breaks added in code only for legibility for screen-reading