What's the best way to group saved search template...
# advancedpdf
b
What's the best way to group saved search template results together on 1 pdf for custom picking ticket? i.e. say a search returns 10 results and the first 6 are for one order and the remaining 4 are a different one. I need 2 pdfs to print out. I've come up with a few ways but not sure what the best is or what is possible. 1. use
pdfset
and
pdf
in the code, but I'm not sure how to group multiple results together and then start a new pdf when the order changes while simultaneously ending the first pdf a. can you do something within an
if
statement like
</pdf> <pdf>
and have it carry info over to subsequent results? i.e. ending the one grouping/page and starting another 2. can you create a macro outside a pdf (I'm assuming not)? The idea is to leverage a macro like this. a. If not, then can you create a pdf within a pdf to use that macro to do something like
<pdf><pdfset> using the macro here to generate new pdfs </pdfset><pdf>
b. the goal here being a unique pdf per grouping 3. use the linked macro and instead of creating a unique pdf per grouping/order, use
pbr
to force new pages/orders. I'm not sure how well this would work with large orders that take up more than 1 page, but I think it'd be fine since the
table
attribute naturally forces page breaks as needed 4. is there another and/or better way? Thanks in advance!
s
You need to achieve two things to do this: The first is the proper sorting of your search results, such that all results are consecutive (i.e. the first six results for the first PDF are all before the results for the second PDF). You'll ned to use ?sort_by, and a variable to compare the current sorting column to the previous value, something like:
The second is figuring out how to separate the results, either into separate pdfs, using a pdfset, separate pages, or just separate tables. The Multi-currency Statement template gives an example of how to separate results into multiple PDFs
b
thanks, I'll review that example. The saved search sorts the results by internal id of the order, so they are already properly sorted, now it's just getting the chunks to show up on unique pages.
s
the relevant bit then, is the assigning of a variable to track the prior value of whatever your indicator column is to know when to start a new pdf, and comparing it to the current value