是否可以通过基于特定字段的公共值进行分组将一个大项目表分成较小的项目表?
例如,如果项目记录中有一个名为“类别”的字段,并且列表选项为“类别A”,“类别B”和“类别C”,那么该表可以分为3个较小的表吗?
[高级PDF模板引擎中的语法类似于:
<#iftrue>
<table></table>
<#else>
<table></table>
[我建议您找到一个与您想要的东西相似的PDF,然后复制/编辑适合您的代码。
但是,通过一些实践,我认为您会发现使用JavaScript和XML创建PDF更加容易。我是从头顶开始这样做的,所以其中有些可能会关闭。如果您需要帮助,或者我出错了,请随时与我们联系。
该设置是一个用户事件,一个Suitelet和一个XML文件。
/**
* @NScriptType UserEvent
* @NApiVersion 2.0 // 2.1 if you can
*/
define(["N/anyLibrariesYouNeed"), function(anyLibrariesYouNeed) {
function beforeLoad(context){
if (context.type === "view") {
context.form.addButton({
id: "custpage_print_pdf",
label: "Print PDF",
functionName: 'window.open("link_to_suitelet")'
}
return {beforeLoad: beforeLoad}
})
/**
* @NScriptType Suitelet
* @NApiVersion 2.0 // 2.1 if you can
*/
define(["N/file", "N/search", "N/anyLibrariesYouNeed"], function(file, search, anyLibrariesYouNeed) {
function onRequest(context) {
// Load the PDF, which is just an XML file
var myPDF = file.load("path_to_your PDF").getContents();
// Load the search
var mySearch = search.load({id: "mySearchId"});
// Do some stuff with the results ...
var myResults = [];
mySearch.run.each(function(result){
// ... like generate a </table> or group results with Lodash
})
//Just make sure all the placeholder text in your XML (PDF) file is replaced. If it's not do ...
myPDF = myPDF.replace("Placeholder", "With this");
//Finally, render the PDF from XML using the bigfaceless engine provided by NetSuite. The setup for bigfaceless is in the XML file.
context.response.renderPdf(myPDF);
}
return {onRequest: onRequest}
})
context.response.renderPdf(myPDF)
呈现为PDF的占位符XML文件//big_face_less_tag_goes_here and something like DOCTYPE XML
<pdf>
<head>
<style>
table tr th td {
border: 1px solid black
}
</style>
<body>
Placeholder
</body>
</pdf>
希望有帮助。如果您需要帮助,请大声疾呼!