Tinderbox Forum

Trying to use Link Type value as variable

Is there a way to capture the Link Type as a value and place it in a String by using an Agent, Rule, or Stamp?

Can you explain what you are looking to do in the action code using the “link type”? It is helpful for the forum to know what the problem one is looking to solve is.

Sure, sorry about that. I’m creating an industry ecosystem matrix with Organizations linked to their products, products are linked to features, and features linked to benefits. Organizations are also linked to competitors. I’ve figured out how to have the features and benefits roll up to the organization level, which is pretty cool. I have various labels for the links: Product, Service, Feature, Benefit, Competitor. I would like an outbound Link Type, or Link Label, to populate an attribute, $Type, in a note. For example, if I use a link labeled Benefit from a one note to another I want the original note’s $Type to be “Benefit”.

Hope this makes sense.


I’m still not sure I fully understand (things are always clearer in our mind’s eye than written onto the page :)) but…

So, I have note A and note B. If I make a link from note A to note B and I give that a link type of “Benefit”, you want note A’s $Type attribute to hold the value “Benefit”. Is that the case?

If so, $Type likely needs to be a Set as if a note has outbound links of more than one type, you’ll need to capture more that one value. Using a Set ensures it holds only one instance of any discrete value.

Currently the way to do this type of task is semi-manual. Action code has no access to the list of link types. Rather you’d use linkedTo(), specifying the desired link type literally in your code. You test linkedTo() in an if() conditional and for links where the condition is true to set $Type to the value of the tested-for link type.

I think AppleScript is likely a better way ahead in this case and that does (or will soon) give scripted access to link types.

Actually, if you have a small number of link types, this can be done using link actions, which you find at the bottom of the link tab in the documents inspector.

Each link type can have its own action. So, if I understand correctly what you’re trying to do, if you set the link action for the “Benefit” type to the following:


then anytime you make a link of the type Benefit to a note then the target note of that link would have “Benefit” added to the attribute $Type. Switching “destination” to “source” would set $Type for the origin of the link.

I like and use link actions but, personally, I find them a challenge to maintain if there are too many types to manage because I forget they are there and what they do. (That’s completely personal. TBX can handle as many as you want to use.) So depending on what you are doing and your own preferences, this approach may not scale well.


Chapeau @bcrane! A very new feature I’d completely overlooked and which, now I reflect, was added for just such a purpose. :face_with_hand_over_mouth:

See more on Link Actions and the Links Inspector.

Link actions are per-Link type. IOW, every time a link of that type is created, this action is run. So, you might need to consider a conditional enclosing if(){} should you be using the same link type in a setting where you do want the action to occur and where you do not.

1 Like

Delicious! Worked like a charm. Used $Type(original)=$Type+“Benefit”. What I especially like is that sometimes product can be both a product to an organization and a feature to another product, this lets me handle them attributes for this through linking. Exactly what I was looking for. :grin: :pray:


Thanks for this post! I was trying to find a way to measure student votes on a number of possible ideas. Each student had five votes to spend, and they could allocate them among the ideas as they chose (e.g. they could give all five to one project, three to one and two to another, one to five, etc.). I put all the students on a map with the ideas and was using links with numbers assigned to the type (1-5) to record their votes. Instead of having to manually count up the votes on each idea, I was able to use what I learned from this post to make the action do the work of incrementing the vote counts in the destination (Action code: $Votes(destination)=$Votes(destination)+1).


Sweet!!! Makes me very happy to hear that you’ve gained value for the community efforts.

Like your application, BTW. :slight_smile:

Have you see the videos yet?

We’ve come a long way since the start of this thread. A lot of great learning to share.