Tinderbox Forum

Agent designator in export code

Hi - the scope of a “agent” designator is limited to the $Query of the agent but I would like to access an attribute of the agent in my export template.
The attribute is $CurrentDeveloper (String) and the export code needs the value of this attribute to select specific childs of a parent note to calculate the sum of an attribute of those childs.

like:
<td>^action($MyNumber=sum_if(children,$Developer==$CurrentDeveloper(agent),$Storypoints);)^^value($MyNumber)^</td>

doesn’t work since the designator in $CurrentDeveloper(agent) will no be valid in the export code…

Any ideas?

If this is being run on an alias, then you want $CurrentDeveloper(parent) as the agent is the parent of the alias (but not the alias’ original).

Worked - perfect - many thanks - I think I tried all other options :wink:

grmpf - next problem:

^action($MyNumber=sum_if(children,$Developer=="Ted Lasso",$Storypoints);)^

works fine in my export template. If I use

^action($MyNumber=sum_if(children,$Developer==$CurrentDeveloper(parent),$Storypoints);)^

It doesn’t. I tested $CurrentDeveloper(parent) - returns exactly the string I need… but still the find doesn’t work as if I use the string in double quotes… must be something easy…

At this point the smart thing to do is take a pause and dump out, to $Text or attributes, the values for $Developer and $CurrentDeveloper(parent). If necessary, copy content out to a code editor or BBEdit or the like and look for oddities like non-printing characters (e.g. a trailing line break). This step always feel like extra work when one might just think ‘think’ a solution. But strings that don’t behave as they should often aren’t quite the strings we assumed them to be!

I did - I wrote $CurrentDeveloper(parent) to $MyString and used value($MyString) to write out the value - the string is there. Copied everything to Bbedit and back to TBX… still doesn’t work…

doesn’t do the job:
<tr><td>^title^^value($CurrentDeveloper(parent))^2</td><td>^action($MyString=$Text.replace ("\n"," "))^^value(MyString )^</td><td>^action($MyNumber=sum_if(children,$Developer==$CurrentDeveloper(parent),$Storypoints);)^^value($MyNumber)^</td></tr>

works fine:

<tr><td>^title^^value($CurrentDeveloper(parent))^2</td><td>^action($MyString=$Text.replace ("\n"," "))^^value(MyString )^</td><td>^action($MyNumber=sum_if(children,$Developer=="Ted Lasso",$Storypoints);)^^value($MyNumber)^</td></tr>

I leave it for today - my creativity has gone to sleep for today and I will follow soon :wink:

Hmm. I didn’t mean use ^value()^ (another transform) but rather just write the two items to the agent’s $Text (or to two empty String attributes.

I don’t understand why a string attribute doesn’t work the same way as a string phrase.

I’m not sure if I do understand your last hint - but this one will not do it too:

<tr><td>^title^^action($Text(parent)=$CurrentDeveloper(parent))^</td><td>^action($MyString=$Text.replace ("\n"," "))^^value(MyString )^</td><td>^action($MyNumber=sum_if(children,$Developer==$Text(parent),$Storypoints);)^^value($MyNumber)^</td></tr>

another failed try:
<tr><td>^title^^action($Text(parent)=sum_if(children,$Developer==$CurrentDeveloper(parent),$Storypoints))^</td><td>^action($MyString=$Text.replace ("\n"," "))^^value(MyString )^</td><td>^value($Text(parent))^</td></tr>

and - this one will do it:
<tr><td>^title^^action($Text(parent)=sum_if(children,$Developer=="Ted Lasso",$Storypoints))^</td><td>^action($MyString=$Text.replace ("\n"," "))^^value(MyString )^</td><td>^value($Text(parent))^</td></tr>

I’m proposing the alias template write to their $Text temporarily (we can clean later). One solution is to make a new template with the code:

<pre>^value($Developer)^
^value($CurrentDeveloper(parent))^</pre>

You can view this in export & preview modes to look for possible differences.

Do all aliases fail the comparison, or only some? Might there be something in the actual values being compared (e.g. characters that can also be regex characters, etc.). But with this sort of problem you really need to see the values, The rest of the template code, at this point, is just an annoyance. Pare back to get a really simple test so as to have as few additional possible factors as possible. Though I don’t think (yet) that it is so here, it could be something else in the template going awry. Only by tearing down so small tests can one easily flush the error out.

Can you make a small file that shows the problem? Or I’m happy to look at the file privately if that help (in which case send me a forum message).

Note: @webline kindly shared a file privately with me, most helpful.