Tinderbox Forum

Action code and Agents Insight: Trick when using .links()

Here is a useful tip. if you use action code like links[(item|group)].kind.[linkType].attribute with agents then you’ll want to keep this in mind.

if you’ve linked a note to another note and are using linkTypes, the links[(item|group)].kind.[linkType].attribute is a great way to keep the attribute value in your notes synced. For example, if you like a person to a company you can have the company name pass to the person’s name note, e.g.,
$Organization=links.inbound."Person".$ShortTitle. This will pass the ShortTitle. Or, in my case I’m passing note IDs to create a cross-reference list for indexes and glossaries, e.g. if($IsAlis==false){$CrossRefItem=links.outbound."Person".$ID;}; and I’m using agents to produce the index.

Here is the tip, not sure you caught it. In your TBX if you run an agent against your notes the agent will create an alias and the alias will run the links action code on itself. As it has no links the $CrossRef attribute will have no value. So, if you wrap the links code with a condition so that it only runs if the note is NOT an alias, then the alias will retain the value of the original note. This will working a lot of situations, not just with this example .