Sorry for the Cross Posting but I don't know what ...
# suitescript
m
Sorry for the Cross Posting but I don't know what is the right channel to post the request (I already posted it on #C466X49JB ). 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 from 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.
s
You can append unique characters to the prefix "formulatext" or any other formula type, like this:
column = new nlobjSearchColumn("formulatext_color");
column.setFormula("{item.custitem_flb_santoni_colore}");
Then, access it in the template as:
template_rows.formulatext_color
👍 1
m
Thanks Scott!!