Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Exporting items with their parents (Read 2575 times)
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Exporting items with their parents
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?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Exporting items with their parents
Reply #1 - 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.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Exporting items with their parents
Reply #2 - 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.
Back to top
 
« Last Edit: Dec 17th, 2015, 11:34am by Derek Van Ittersum »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Exporting items with their parents
Reply #3 - Dec 17th, 2015, 3:21pm
 
Take a look at ^action()^. That might help.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Exporting items with their parents
Reply #4 - 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.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Exporting items with their parents
Reply #5 - 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!
Back to top
 
« Last Edit: Dec 19th, 2015, 6:57pm by Mark Bernstein »  
WWW   IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Exporting items with their parents
Reply #6 - Dec 19th, 2015, 9:17pm
 
Whoops. I had the "greater than" sign when I meant the "less than" sign. Harrumph.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print