Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Exporting items with their parents
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1450300044

Message started by Derek Van Ittersum on Dec 16th, 2015, 4:07pm

Title: Exporting items with their parents
Post by Derek Van Ittersum on Dec 16th, 2015, 4:07pm

Hi,

I'm working on a tricky export problem that I'm having trouble wrapping my head around. I have an agent collecting notes that meet a condition, and I'd like to export those notes along with the name of their parent. But, I don't want that parent name repeated for every note, I want children of the same parent grouped together.

Here's the data structure:

Project Notes
----Project A
--------task 1 [tags: read, write]
--------task 2 [tags: write]
--------task 3 [tags: read]
----Project B
--------task 4 [tags: write]
--------task 5 [tags: read, write]
--------task 6 [tags: read]

I have an agent collecting all "task" notes with $Tags.contains("read"). Works great.

I'd like to export to get something like this:

Project A:
- task 1
- task 3

Project B:
- task 5
- task 6


Right now, it's easy enough to get the following:

Project A:
- task 1

Project A:
- task 3

Project B:
- task 5

Project B:
- task 6


However, I don't need the project name repeated every time. I tried to create an agent that would search for all Projects that had children with $Tags.contains('read"), but I didn't see an operator for that. I'm guessing maybe I'm thinking about this the wrong way around. Advice?

Title: Re: Exporting items with their parents
Post by Mark Anderson on Dec 16th, 2015, 5:54pm

I'd get each project's rule to store in a list collect_if(children,$Tags=="read",$Path) as that seems to give you the listing you want in your final comment.

Title: Re: Exporting items with their parents
Post by Derek Van Ittersum on Dec 17th, 2015, 11:34am

Thanks for pointing out "collect_if" Mark, that's exactly what I needed.

Here's what I did:

Created an agent named "read". Query: $Prototype=="ProjectNotes" [this finds the "Project A" and "Project B" notes from the example above]

Action:

$TagExport=collect_if(children,$Tags.contains($Name(agent)),$Name); $TagExportList=format($TagExport,"","\t- ","\n","")

Template:

^title^:
^value($TagExportList)^

Now, this does exactly what I want. But, just to increase my learning about exporting, is there any way to do this without creating the attribute holding areas (e.g, $TagExport and $TagExportList)? I was thinking I could do the collect_if via an action in the export code itself ... but I haven't been able to work that out.

Title: Re: Exporting items with their parents
Post by Mark Anderson on Dec 17th, 2015, 3:21pm

Take a look at ^action()^. That might help.

Title: Re: Exporting items with their parents
Post by Derek Van Ittersum on Dec 19th, 2015, 4:11pm

So, I'm trying this same technique with a slightly different condition and not getting good results.

agent action:

$WeekExport=collect_if(descendants,$StartDate > (today + 7 days),$Name);$WeekExportList=format($WeekExport,"","\t- ","\n","")


Here's what's going wrong: I'm getting all descendants, not just the descendants with a StartDate sometime in the next week, as I was hoping. Am I using collect_if wrong now? Is there some formatting for the middle part? I have tried what seems like every permutation of quotes, parentheses, and no formatting around the "today + 7 days" portion.

Title: Re: Exporting items with their parents
Post by Mark Bernstein on Dec 19th, 2015, 6:57pm

I believe you want

     date("today+7 days")

As always, when a query gives you unexpected results, it helps to break down the query into components that are simple -- too simply to fail. One of them is failing!

Title: Re: Exporting items with their parents
Post by Derek Van Ittersum on Dec 19th, 2015, 9:17pm

Whoops. I had the "greater than" sign when I meant the "less than" sign. Harrumph.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.