Tinderbox Forum

Finding notes on a product

I am entering notes (Prototype pNote) about various products. A set attribute, Products, lists the products that a note pertains to. For example, assume A, B, C… are products. A sample note might be named “No longer supported by supplier” with Products = “A”. (Most notes pertain to one product, but a few reference several products, hence my use of a set attribute.)

I also have an agent (prototype is pProduct) for each product that gathers notes pertaining to that product. Agent names are the product name (e.g. A) and each such agent also has its attribute, Products, set to its name.

Example: two notes -
“No longer supported by supplier” (Products set to “A”)
“Competitor lowers price” (Products set to “A;B”)

The agent, named A, also has its Products attribute set to “A” and has the query:
($Products.contains($Products(agent)) & $Prototype == “pNote”)

[Note: the above is a distillation and abstraction of my database which has nothing to do with products.]

What I’d like to add is a housekeeping agent that finds any notes whose products do not have a corresponding agent. Example: note “union strikes, no production for now”, Products = “C”.
I want to be sure that there exists an agent, C, that gathers all notes pertaining to C.

I have a query that begins with: $Prototype==“pNote”

But then I’m stuck - I want to be sure the note appears as an alias in one of the products agents. In other words I want there to exist an agent C.

In words, I’d like to code: $Prototype==“pNote” & {there exists an agent whose Product is same as note’s Products}

(here’s my problem, I’m searching for something that is related to something else that needs to be searched for.)

Any suggestions for the query?

I think I’ve made things complicated. Let’s just say I’m entering notes, and each note is related to one or more topics (topics are stored in a set attribute and are single words, like Life, Death, Taxes.)

I also have an agent for each topic that gatherers all notes for that topic. Now I want a housekeeping agent that finds any topics mentioned in notes that do not have a corresponding agent.

Maybe I don’t need a housekeeping agent. Some other construct might work just as well, like the attribute browser, which I’m not well versed at.

Off the top of my head, I would do this by having a boolean condition – say $HasAgent – and the action code for each agent would set $HasAgent=true; for every note the query finds. You don’t need to have a different boolean for each topic flavor.

Then all you need is a nanny agent that looks for $HasAgent==false.

(Sometimes a Venn diagram is helpful when sorting out the how to for these puzzles.)

Now, that sounds promising! Thanks so much. I’ll tackle this tomorrow morning.

This works up to the point where you’ve too many agents and things are a mess. I’d encourage you to get acquainted with Attribute Browser which offers a more scalable growth in your document.