Explode a note into agent


(Jawn Lam) #1

I’m sorry if I’m missing something basic here, but is there a way for me to Explode a note into Agents?

Let’s say I’ve compiled a list of authors into a single note. And now I want to Explode that note into a bunch of agents such that
$AgentQuery="$Authors.contains($Name(agent))"

Is this possible?

Thanks.


(Mark Anderson) #2

In short, no. Indeed, except in a very small doc this might not be the best solution. Anyway, there is another route to discovering the same relationships: explode the original listing note and apply a prototype to all the exploded note. That prototype, whose own edict should be disabled, should have an edict like this:

linkTo(find($Prototype=="Paper"&$Authors.contains($Name(that))),"authored");

The above is from one of my own docs where I’ve linked every author to any - in my case - paper of which they are an author. In natural language we might describe it thus:

Make a link, of link type ‘authored’ to every note of prototype ‘Paper’ whose ‘$Authors’ (multi-value) attribute contains a value that is an exact match for the ‘$Name’ of the note executing the find().

For completeness, if the target attribute in the papers were a single-value String field, for example $MyString, then we can use a less processor intensive find query using the ‘==’ equals operator. Thus:

linkTo(find($Prototype=="Paper"&$MyString==$Name(that)),"authored");

So, why an edict and not a rule? Because in a document of size, that query, with all the ‘.contains()’ calls can take a while to run and a rule runs constantly. Edicts (or a manual stamp using the same code) are a better choice as they run once on creation or being edit and then only once an hour. In truth, if this linking task only needs doing once, a stamp might be a better option.

To give an idea of use at scale, in my example above I was linking 2116 Author notes (generated by exploding a list of $Authors) to 1169 Conference Paper notes they had (co-)written.

Once done, the Roadmap dialog can be used to show the articles linked from a particular author’s note. This might seem less accessible info than using agents. But, in the scenario above, imagine trying to work in a document with over 2,000 agents running!


(Jawn Lam) #3

Mark, if I ever meet you in person, I’m buying you a beer (or beverage of your choice).