Short description: Is it possible to combine saved...
# advancedpdf
b
Short description: Is it possible to combine saved search templates into 1 template without using SuiteScript? I have a wonderful table join issue that means I cannot run 1 search to get all the data I need to create a batch of pdfs. Long description: I'm creating a custom packing list form because we have made a decision to set up "kit" items as assemblies in our ERP. This was done for accounting and inventory reasons, namely having the COGS and Revenue ride with the "kit" item (normal kit items have the revenue ride with the kit item, but COGS stays on components, making reporting more difficult). Because of this I've created a flag on our assembly items being treated as kits so I know when to show the components of the "kits" for picking purposes (packing list doubles as picking ticket even though we have pick/pack/ship). I've created an item saved search template that grabs all the information I need from the order as well as has the proper join so I can get to the member items of these "kit" items so I can properly display their name/description, quantity, and bin (if they have one). This is great except for we have multiple brands that sell our products and we can list the same product with more than 1 brand. When printing the packing list, we will want the brand of the order to be referenced on the printed form. This data is stored as a field on the order record, it's a custom record select value. This is where the join issue comes into play. It's possible to create additional fields on the order record that are sourced from the brand custom record, but that seems like over engineering and will add more overhead to the form than should be required when I could simply use a join. I'm open to any thoughts on how best to approach this if anyone has done it before, or something similar.
r
Qualifier: Replying to only the short description. Have you looked into the SuiteAnalytics Workbooks to see if your deeper joins are available there?
b
I haven't. Deeper joins should be available there but can you drive an advanced PDF from them?
r
I just saw that one, I don't believe you can.
b
thanks for the thought!
you can use suiteanalytics workbook with suitescript, so i might look into that
e
Create a saved search for your main dataset and then create a second saved search for the join. You can join the 2 results set int one JSON object that you can use to generate the PDF using the N/render module.
/*
function that merges two datasets into one dataset (primary is resulting dataset) */ function mergeDataObject(primary, secondary) { for (var key in secondary) { var pobj = primary[key]; var sobj = secondary[key]; if(pobj === undefined) { primary[key] = sobj } else { if(sobj != null) { for (var prop in sobj) { if(!pobj.hasOwnProperty(prop)) { // primary object doesn't have this property so add it pobj[prop] = sobj[prop]; } } } } } }
You can use that function to merge 2 JSON objects. The resulting JSON object will be the primary object. The caveat is that you will need to have the second saved search sorted on the field that you are going to be using for the join.
b
right, but that requires suitescript. I was seeing if there was an option without that. Nevertheless this is the route I think i'm going to have to go anyways since i'll need one-off capability and batch printing capability. thanks for the snip!
i'm also looking into using the query module instead but need to make sure i can get all the data first using analytics in the ui. Haven't worked with that yet, so it's going to be a learning curve.