Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
agent showing notes with certain link-types (Read 922 times)
andreas grimm
Full Member
*
Offline



Posts: 39

agent showing notes with certain link-types
Oct 05th, 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!

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent showing notes with certain link-types
Reply #1 - 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.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
andreas grimm
Full Member
*
Offline



Posts: 39

Re: agent showing notes with certain link-types
Reply #2 - Oct 8th, 2016, 4:33pm
 
Just to point. Perfect as always. Thank you, Mark A.

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print