Hello! I am trying to pass a searchresult to an Ad...
# advancedpdf
m
Hello! I am trying to pass a searchresult to an Advanced PDF Template with
renderer.addSearchResults()
. If the search is simple everything works as expected: I define the
<#list>
tag and I retrieve the fields correctly The problems arise when I use joined fields and/or multiple formula fields. If I use joined fields, I cannot find a way to retrieve the field within the template. If I define more than one formulatext for example, it seems that the latter overwrite the former and only the last defined formula field is available in the template. Take this code for example.
Copy code
var filters= [];
filters.push(new nlobjSearchFilter("internalid",null,"is", 40556971));
filters.push(new nlobjSearchFilter("mainline",null,"is", "F"));
filters.push(new nlobjSearchFilter("shipping",null,"is",  "F"));
filters.push(new nlobjSearchFilter("taxline",null,"is", "F"));
filters.push(new nlobjSearchFilter("accounttype",null,"anyof","COGS"));
var columns=[];
columns.push(new nlobjSearchColumn("externalid", "item"));    
column=new nlobjSearchColumn("formulatext");
column.setFormula("{item.custitem_flb_santoni_colore}");
column.setLabel("color");
columns.push(column);
column=new nlobjSearchColumn("formulatext");
column.setFormula("{item.custitem_flb_santoni_taglia}");
columns.push(column);
columns.push(new nlobjSearchColumn("accounttype"));    
columns.push(new nlobjSearchColumn("quantity"));
var searchresult = nlapiSearchRecord("transaction", null, filters, columns );
var renderer = nlapiCreateTemplateRenderer();
var f = nlapiLoadFile(doc_config.template_id);
var template = f.getValue();
renderer.setTemplate(template);
renderer.addSearchResults('template_rows', template_rows);
Could anybody help me? Thanks in advance.
d
Not sure if you still looking for a fix here, but I was able to do something similar by using different formula column labels
e.g. new nlobjSearchColumn("formulatext_colore"); new nlobjSearchColumn("formulatext_taglia"); then use formulatext_colore & formulatext_taglia as the tag reference in #list