Trouble with export template

See that attached file. I’m having trouble with an export template. I have an agent that is returning a set of notes. I am applying a template to those notes. I only want to export the results of the agent, but the template it processes not only the result of the agent but the found note’s children as well. I don’t want this. I just want the orgs, not the products. Anyone have any idea what I’m doing wrong or what I need to do to my template to only export the orgs and not their children?


AgentOrgReport.tbx (147.2 KB)

Your CompAnalysisItem template reads

<tr>
<td>^value($Type)^</td>
<td>^value($Name)^</td>
<td>^value($Organization)^</td>
<td>^value($Features)^</td>
<td>^value($Rank)^</td>
<td>^value($PricingTier1Name)^</td>
<td>^value($PricingTierr1)^</td>
<td>^value($PricingTier2Name)^</td>
<td>^value($PricingTier2)^</td>
<td>^value($PricingTierr3Name)^</td>
<td>^value($PricingTierr3)^</td>
<td>^value($StartDate.format("l"))</td>
<td>^value($EndDate)</td>
<td>^value($URL)</td>
</tr>
^children(/Templates/CompAnalysis page/CompAnalysis item)

After exporting a row, it asks Tinderbox to export a row for each child. Which Tinderbox is obediently doing.

The above explains the literal ‘how’, what the underlying cause may still be confusing as the aliases under ‘agent’ have no (visible) children. The cause is this:

When exporting, aliases also behave as if their original note’s children were their own children.

Above copied from here.

In fact if you add a child to one of your ‘Prod’ notes, it too will show up in the export.

Here, just omitting the ^children(... line in the above template fixes the problem. If you needed to use the template in original and alias settings you could enclose that last line in a test, e.g. ^if($IsAlias==false)^^children(...)^^endIf^.

^^^ Edit: duh, that is ==‘false’ not ‘==true’ as originally written, and not using action code { parentheses.

The fact I had to hunt around for the above quote reminds me this needs to be better documented. Indeed, the whole alias article probably wants splitting down into several notes (if only for better hypertextual reference).

1 Like

OK, here is an edited version of your doc AgentOrgReport1.tbx (162.7 KB)

I’ve added a ‘Thing1’ child to Org1/Prod3. In your original agent, now ‘agent1’ you can the the above effect of pulling in children/descendants of aliases’ originals even more clearly. Agents ‘agent2’ and ‘agent3’ clone ‘agent’ one but use a different pair of templates (numbered as for the agent). #2 and #3 give the same preview, but template #3 used on the /orgs container is different from ‘agent3’ as it is testing whether it is exporting an alias or an original note.

This is another example where, as with find() queries, context disambiguation using $IsAlias comes in handy. Not something most people need but very useful when you do.

Yup, I did not think that Tinderbox was at falut. This was entirely a problem “between the keybaord and the chair.” :wink:

I learned something new. I always thought you had to have ^(children)^ in the sub-template to process the children. So obvious now that this is NOT the case. :pray:

Thanks for the really engaging call this morning Mark. Great insights shared all around.

1 Like