Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> agent showing notes with certain link-types
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1475711865

Message started by andreas grimm on Oct 5th, 2016, 7:57pm

Title: agent showing notes with certain link-types
Post by andreas grimm on Oct 5th, 2016, 7:57pm

Question: I'd like to have an agent that collects all the notes that have "outbound links" where the link-type is "agree".

I've read a lot about "links.outbound" and "link-type" or "linkType" stuff in this forum. But I couldn't find any specific help on how to write an agent-query that would deliver on my question stated above.

Ideas?

Cheers!


Title: Re: agent showing notes with certain link-types
Post by Mark Anderson on Oct 6th, 2016, 3:39am

To query whether a given note has links to or from other notes, possibly only of a given link type you need to use the query terms linkedTo() or linkedFrom(). Other action codes using linkage have non-query tasks. linkedTo()/linkFrom() are involved in the creation of links. The unlinkTo()/unlinkFrom() codes are involved in removing links. The links() operator builds a list of attribute values based on linkage patterns.

I'd recommend reading the aTbRef articles on both linkedTo() and linkedFrom(). Each article has an example which I'll show here below.

To test if any note using the 'Event' prototype has an outbound link of the 'untitled' link type the agent query would be:

    $Prototype=="Event" & linkedTo("*", "*untitled")

Conversely, to test if any note using the 'Event' prototype has an inbound link of the 'untitled' link type the agent query would be:

    $Prototype=="Event" & linkedFrom("*", "*untitled")

In both examples, the query includes other terms. That can be an and or an or join - the examples above use an 'and' join indicated by the ampersand ('&') character. Thus: "find all notes that are Event-prototyped AND have an outbound link of the 'untitled' link type.

linkTo() tests links outbound from the note being queried, i.e. "is this note linked to ...". Conversely, linkFrom() looks at inbound links, i.e. linked from others.

linkTo() and linkFrom() are designed to test a single link between a given pat of notes - the current note and the note described in the first input of the code. To allow searching all links, special asterisk ('*') operator is offered. You cannot use group-based designators, e.g. children, in these codes. If you need to find linked items that are, for example, children of the current note you need to use additional query terms to clarify that relationship constraint.

It's easy to flip the mental working of the to/from, i.e. in the linkedTo() example "what is linked from this note?" causing you to thing to use the wrong operator. I'm very prone to this myself. If getting odd results, I generally make a new note with 5-10 notes, add link (types) of the sort used in my main file and that try out my query.  With a small test that reduces extraneous data, it's easier to check you've used the right to/from code and are getting expected results.

Title: Re: agent showing notes with certain link-types
Post by andreas grimm on Oct 8th, 2016, 4:33pm

Just to point. Perfect as always. Thank you, Mark A.


Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.