JacksonP
07/27/2020, 4:38 PMSandii
07/27/2020, 4:44 PMJacksonP
07/27/2020, 4:59 PMJacksonP
07/27/2020, 5:00 PMvar checkSearchObj = search.create({
type: "check",
filters:
[
["tobeprinted","is","T"],
"AND",
["internalid","anyof",allCheckedIds],
"AND",
["type","anyof","Check"]
],
columns:
[
"internalid"
]
});
var results = checkSearchObj.run().getRange(0,1000);
log.debug('results', JSON.stringify(results))
var renderer = render.create();
renderer.setTemplateById(118);
renderer.addSearchResults({
templateName: 'Checks Account - ',
searchResult: results
})Sandii
07/27/2020, 5:12 PMJacksonP
07/27/2020, 5:13 PMLuiz Morais
07/27/2020, 5:16 PMJacksonP
07/27/2020, 5:17 PMJacksonP
07/27/2020, 5:18 PMLuiz Morais
07/27/2020, 5:21 PMJacksonP
07/27/2020, 5:21 PMJacksonP
07/28/2020, 6:26 PMKit Vera (she/her)
07/28/2020, 10:16 PMKit Vera (she/her)
07/28/2020, 10:16 PMJacksonP
07/29/2020, 12:59 PMClay Roper
07/29/2020, 2:10 PMinternalid column you've specified as your search result column.Clay Roper
07/29/2020, 2:11 PMTemplateRenderer.addRecord /help/helpcenter.nl?fid=section_456543212890.htmlJacksonP
07/29/2020, 2:14 PMClay Roper
07/29/2020, 2:21 PMaddRecord method and pick up those record fields (and some fields a single join away) within the template.JacksonP
07/29/2020, 2:22 PMKit Vera (she/her)
07/29/2020, 8:30 PMKit Vera (she/her)
07/29/2020, 8:30 PMvar folder_id; //the internal ID to save the test HTML file
var allCheckedIds; //The check IDs for search filter
var datasource = {
lines: [],
summary: {
total: 0
}
};
var checkSearchObj = search.create({
type: "check",
filters:
[
["tobeprinted", "is", "T"],
"AND",
["internalid", "anyof", allCheckedIds],
"AND",
["type", "anyof", "Check"]
],
columns:
[
search.createColumn({
name: "internalid",
label: "id"
}),
search.createColumn({
name: "tranid",
label: "tranid"
}),
search.createColumn({
name: "amount",
label: "amount"
})
]
});
checkSearchObj.run().getRange(0, 1000).forEach(function (result) {
var this_obj = {};
//I use the labels to set the column names to avoid ambiguity when using
//formulas
checkSearchObj.columns.forEach(function (col) {
this_obj[col.label] = result.getValue(col);
});
datasource.lines.push(this_obj);
datasource.summary.total += Number(this_obj.amount);
return true;
});
//log.debug('transactions.summary', JSON.stringify(transactions.summary));
var renderer = render.create();
renderer.setTemplateByScriptId('CUSTTMPL_MY_TEMPLATE');
renderer.addCustomDataSource({
format: render.DataSource.OBJECT,
alias: 'results',
data: datasource
});
var contents = renderer.renderAsString();
contents = contents.replace(/&([^;]+(?!(?:\\w|;)))/g, '&$1');
//Do this to test the raw output of the file
if (runtime.getCurrentUser().role === 3) {
var fileObj = file.create({
name: 'template_merged.html',
fileType: file.Type.HTMLDOC,
contents: contents,
description: 'These are the merged results from ' + (new Date()).toString(),
encoding: file.Encoding.UTF8,
folder: folder_id,
isOnline: true
});
fileObj.save();
}
context.response.renderPdf({xmlString: contents});Kit Vera (she/her)
07/29/2020, 8:31 PMJacksonP
07/29/2020, 8:42 PM