This message was deleted.
# advancedpdf
s
This message was deleted.
n
Are you showing the child records on the parent record as a sublist using a search? If not then I don;t believe the the child records are exposed on the parent for you to reference them. If they are then you should see a sublist that starts "recmach".
s
Yes, I'm using a view/search to display the sublist records, and I'm definitley not seeing any sublists in the XML. I noticed the default print template pulls all the sublists into the pdf without issue, so was hoping this was a simple oversight on my behalf. Does this mean it's not possible to expose the children if it's not exposed in the XML as a sublist? Any alternaitve solutions?
r
I accomplish this by code. Not sure if this is an option for you. With N/render you can add additional querys, json, etc.
s
Okay, that sounds like the route to go. Just post a ue button to the record that calls my script to do the heavy lifting and render PDF?
r
yes
add the record to the render method first
Copy code
var itemQuery = query.create({
    type: query.Type.ITEM
});

itemQuery.columns = [
    itemQuery.createColumn({ fieldId: 'id' }),
    itemQuery.createColumn({ fieldId: 'custitemgm_longitemdesc' }), //Long Desc
    itemQuery.createColumn({ fieldId: 'itemid' }) ,// SKU
    itemQuery.createColumn({fieldId:'displayname'})
];
rederFileRec.addQuery({
    templateName: 'itemSearch',
    query: itemQuery,
});
return rederFileRec;
then add add a query for sub data
s
Fantastic! Thank you for going the extra mile.
r
you access the query data with the name you put in templateName: 'itemSearch', <#list itemSearch![] >
itemRecord[2]
your welcome
Im working on an open source module to automate alot of that
<#list itemSearch![] > <#items as itemRecord>
sorry it would be
itemRecord[3]
for example to pull in my code
s
That sounds super exciting! Please keep me in mind when it gets into beta release - I would be happy to test and provide feedback.
Query results look good, but getting a vague UNEXPECTED_ERROR at Object.onAction with my button driven (Print Report) Workflow Action Script : Any thoughts?
Copy code
//Create Query
                var itemQuery = query.create({
                    type: 'customrecord_xxxx'
                });


                // Set Search Filter
                var cond1 = itemQuery.createCondition({
                    fieldId: 'custrecord_xxxxxxx',
                    operator: query.Operator.EQUAL,
                    values: 503
                });


                // Add Columns to Query
                itemQuery.columns = [
                    itemQuery.createColumn({ fieldId: 'custrecord_amount' }),
                  	itemQuery.createColumn({ fieldId: 'custrecord_company' }),
                  	itemQuery.createColumn({ fieldId: 'custrecord_account'}),
       			  	itemQuery.createColumn({ fieldId: 'custrecord_invoice'}),
                  	itemQuery.createColumn({ fieldId: 'custrecord_parent'})
                ];


           		var resultSet = itemQuery.run();
                log.debug('itemQuery Result:', resultSet);

           		//Add Query to Renderer
           		var renderer = render.create();
           		renderer.setTemplateByScriptId({
                  scriptId: 'CUSTTMPL_MY_ADV_PDF'
                });
           		renderer.addQuery({
                  templateName: 'paymentSearch',
                  query: itemQuery
                });

           		var pdf = renderer.renderAsPdf();
r
I always start with a suite let test page
I use response.write and log.debug to write out what I think I know and some times I am surprised I dont get what expected
so in the test suitelet I staert with something like var custID =12. then render load record then render add query
that way I know wher eit breaks down
if you can do this then I could help more
I suspect you cant see the error becuase it is buried in NS backend and doesnt expose issue
s
Okay, I will work on moving to Suitelet, and incrementally stepping through. TY
r
I had a render error deep in code functions and couldn't know real error until I tried in a simple hard coded suitelet. then it popped its head up.
good luck
why are you using a Workflow for printing, curious?
if you get your suitelet working by a var custid=15 working forst woulding you just use an inline link or a button to launch url to suitelet serving up the pdf or emailing it?
im not a fan of buttons becuase it limits how many action you can do on a record. it is not realistic to have 10 buttons on a record.
I prefer an inline HTML link to a suitelet
message has been deleted
s
It was just a quick proof of concept. I was more focused on the Query side of things.
r
understand
when you want to add a link via inline html
'<a style="" href="' || 'https://<<youraccount>>.app.netsuite.com/app/site/hosting/scriptlet.nl?script=842&amp;deploy=1&amp;tranid=' || {id} || '&transtype=' || {baserecordtype}|| '"> Send Custom Email</a>'
set something like that as default value
then catch in the suitelet with
Copy code
var sRecordID = context.request.parameters['tranid'];
var sTransType = context.request.parameters['transtype'];
var emmessageID = context.request.parameters['emT'];
hope this helps
s
It does, thank you very much.
Just wanted to follow-up and says thanks. This was a SUPER helpful reference guide. One quick question, can't find good example of using the groupBY inside my query. Keep getting syntax error.
Copy code
// Add Columns to Query
                itemQuery.columns = [
                    itemQuery.createColumn({ fieldId: 'custrecord_amount', groupBy: true })
                ];
r
I have not used group by in N/Query yet. I would try get the query working in https://timdietrich.me/netsuite-suitescripts/suiteql-query-tool/ assuming you know SQL. Start real simple like select ID from table group by ID. and then add stuff to it. Maybe you are breaking what is allowed in the query like trying to return non aggregated columns.
you could also get it working in a saved search first. then add the saved search to render instead of N/query