问题描述
是否可以通过基于特定字段的公共值进行分组将一个大项目表分成较小的项目表?
Is it possible to separate out one big item table into smaller item tables by grouping based upon a common value of a specific field?
例如,如果项目记录中有一个名为类别"的字段,并且列表选项为类别A",类别B"和类别C",那么该表格可以分为3个较小的表格吗?
For example, if the item record had a field called 'Category' and the list options was 'Category A', 'Category B' and 'Category C', could the table be separated into 3 smaller tables?
推荐答案
高级PDF模板引擎中的语法类似于:
There is syntax in the Advanced PDF template engine that's something like:
<#iftrue>
<table></table>
<#else>
<table></table>
我建议您找到一个与您想要的功能相似的PDF,然后复制/编辑适合您的代码.
I would recommend finding a PDF which does something similar to what you want and copy/edit the code to work for you.
但是,通过一些实践,我认为您会发现使用JavaScript和XML创建PDF更加容易.我是从头顶开始进行操作的,因此其中某些功能可能会关闭.如果您需要帮助,或者我出错了,请随时与我们联系.
However, with a bit of practice, I think you'll find it much easier to create PDF's with JavaScript and XML. I'm doing this from the top of my head, so some of it may be off. If you need help, or I've made an error, please don't hesitate to reach out.
设置是一个用户事件,一个Suitelet和一个XML文件.
The setup is a User Event, a Suitelet, and an XML file.
- 用户事件脚本,用于在视图模式下显示一个按钮,单击该按钮可打开Suitelet:
/**
* @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}
})
- 从上述用户事件打开的Suitelet,并将XML文件中的占位符文本替换为条件文本:
/**
* @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}
})
- 占位符XML文件,它使用
context.response.renderPdf(myPDF)
呈现为PDF
- Placeholder XML file which is rendered as a PDF using
context.response.renderPdf(myPDF)
//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>
希望有帮助.如果您需要帮助,请大声疾呼!
Hope that helps. If you need help, just holler!
这篇关于高级PDF NetSuite-按公共字段值分组项目表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!