
[英]NetSuite UserEvent SuiteScript 2.0 not firing on Support Case Create
[英]NetSuite SuiteScript 2.0 How do I create a Bank Deposit Slip (suitelet function) from a UserEvent Button
我是NetSuite和SuiteScript的全新開發人員,我磕磕絆絆。
問題:對於每個存款記錄,我需要創建一個可打印的pdf,其中列出了該記錄中的每筆付款(銀行存款單)。 我想在自定義按鈕上調用此pdf,以顯示在我可以打印的新窗口中。 我不需要將文檔保存在文件櫃中。
1.現在我有一個UserEvent按鈕,可以在視圖和編輯模式中顯示存款。
define([], function () { /** * @NApiVersion 2.x * @NScriptType UserEventScript */ var exports = {}; function beforeLoad(context) { context.form.addButton({ id: "custpage_printdepositslip", label: "Print Deposit Slip", functionName: "onButtonClick" }); context.form.clientScriptModulePath = "SuiteScripts/depositSlips/customDepositSlipButton.js" } exports.beforeLoad = beforeLoad; return exports; });
2.此按鈕從名為“customDepositSlipButton.js”的ClientScript調用clickhandler函數“onButtonClick”。
define(["N/ui/dialog"], function (dialog) { /** * @NApiVersion 2.x * @NScriptType ClientScript */ var exports = {}; function pageInit(context) { // TODO } function onButtonClick() { dialog.alert({ title: "COMING SOON", message: "This feature will eventually create a bank deposit slip" }); } exports.onButtonClick = onButtonClick; exports.pageInit = pageInit; return exports; });
目前這有效,但只創建一個用於測試目的的對話框彈出窗口。 到現在為止還挺好。 測試彈出窗口
這就是我被困住的地方:我不明白如何將它連接到Suitelet上的一個函數,該函數應該從xml生成一個pdf文件。
3.我在一個名為“depositSlipPDF.js”的文件櫃位置設置了一個帶有來自xml腳本的pdf的Suitelet,其功能為“generatePdfFileFromRawXml”,如下所示。
define(['N/render', 'N/record'], function(render, record) { /** * @NApiVersion 2.x * @NScriptType Suitelet * @appliedtorecord deposit */ /** * <code>onRequest</code> event handler * @gov 0 * * @param request * {Object} * @param response * {String} * * @return {void} * * @static * @function onRequest */ function generatePdfFileFromRawXml() { var xml = '<?xml version="1.0"?>n<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">n<pdf>n<body size="letter-landscape" font-size="10">n'; xml += '<table width="100%" align="center">n'; xml += '<tr>n'; xml += '<td>Deposit Number: ' + depositRecord.getFieldValue('tranid') + '</td>n'; xml += '</tr>n'; xml += '<tr>n'; xml += '<td>Date: ' + depositRecord.getFieldValue('trandate') + '</td>n'; xml += '</tr>n'; xml += '<tr>n'; xml += '<td>Total: ' + depositRecord.getFieldValue('total') + '</td>n'; xml += '</tr>n'; xml += '<tr>n'; xml += '<td>Posting Period: ' + depositRecord.getFieldText('postingperiod') + '</td>n'; xml += '</tr>n'; xml += '</table>n'; xml += '<br /><br />n'; xml += '<table width="100%" align="center">n'; xml += '<thead>n'; xml += '<tr>n'; xml += '<th>Date</th>n'; xml += '<th>ID</th>n'; xml += '<th>Customer</th>n'; xml += '<th>Payment Amount</th>n'; xml += '<th>Transaction Amount</th>n'; xml += '<th>Transaction Type</th>n'; xml += '<th>Payment Method</th>n'; xml += '</tr>n'; xml += '</thead>n'; xml += '<tbody>n'; for (var i = 1; i < parseInt(depositRecord.getLineItemCount('payment')) + 1; i++) { if (depositRecord.getLineItemValue('payment', 'deposit', i) == 'T') { xml += '<tr>n'; xml += '<td>' + depositRecord.getLineItemValue('payment', 'docdate', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemValue('payment', 'docnumber', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemText('payment', 'entity', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemValue('payment', 'paymentamount', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemValue('payment', 'transactionamount', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemValue('payment', 'type', i) + '</td>n'; xml += '<td>' + depositRecord.getLineItemText('payment', 'paymentmethod', i) + '</td>n'; xml += '</tr>n'; } } xml += '</tbody>n'; xml += '</table>n'; xml += '</body>n</pdf>'; var pdfFile = render.xmlToPdf({ xmlString: xmlStr }); } return { onRequest: generatePdfFileFromRawXml } });
我如何調用generatePdfFileFromRawXml(); 來自onButtonClick();?
獲得這個目標的信譽可以歸功於Stoic Software ,其中SS2是可以理解的(謝謝你,Eric)和teamtag 這篇文章 ,我得到了這些初始xml數據拉取的代碼。
我也是,我正在嘗試同樣的事情。 我終於工作了,嘗試將你的xml字符串更改為:
var xml = '<?xml version="1.0"?>\n<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">\n<pdf>';
xml += '\n<body font-size="18">\n';
xml += '<table width="100%" align="center">\n';
xml += '<tr>\n';
xml += '<td>Deposit Number: ' + depositRecord.getValue({fieldId: 'tranid'}) + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td>Date: ' + depositRecord.getValue({fieldId: 'trandate'}) + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td>Total: ' + depositRecord.getValue({fieldId: 'total'}) + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td>Posting Period: ' + depositRecord.getText({fieldId: 'postingperiod'}) + '</td>\n';
xml += '</tr>\n';
xml += '</table>\n';
xml += '<br /><br />\n';
xml += '<table width="100%" align="center">\n';
xml += '<thead>\n';
xml += '<tr>\n';
xml += '<th>Date</th>\n';
xml += '<th>ID</th>\n';
xml += '<th>Customer</th>\n';
xml += '<th>Payment Amount</th>\n';
xml += '<th>Transaction Amount</th>\n';
xml += '<th>Transaction Type</th>\n';
xml += '<th>Payment Method</th>\n';
xml += '</tr>\n';
xml += '</thead>\n';
xml += '<tbody>\n';
for (var i = 0; i < parseInt(depositRecord.getLineCount({sublistId: 'payment'})); i++){
if (depositRecord.getSublistText({sublistId: 'payment', fieldId: 'deposit', line: i}) == 'T'){
xml += '<tr>\n';
xml += '<td>' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docdate', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docnumber', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistText({sublistId: 'payment', fieldId: 'entity', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'paymentamount', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'transactionamount', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'type', line: i}) + '</td>\n';
xml += '<td>' + depositRecord.getSublistText({sublistId: 'payment', fieldId: 'paymentmethod', line: i}) + '</td>\n';
xml += '</tr>\n';
}
}
xml += '</tbody>\n';
xml += '</table>\n';
xml += '</body>';
xml += '\n</pdf>';
並查看是否修復了您的Parsing XML錯誤。
使用前兩個答案的輸入,這里是完整的工作解決方案和結果的屏幕截圖:
步驟1)客戶端腳本為自定義按鈕建立一個點擊處理程序,這會抓取我當前記錄的id並將其傳遞給我在新窗口中執行的suitelet
define(['N/url', 'N/currentRecord'], function (url, currentRecord) {
/**
*
* @NApiVersion 2.x
* @NScriptType ClientScript
* @appliedtorecord deposit
*/
var exports = {};
/**
* <code>pageInit</code> event handler
*
* @gov XXX
*
* @param context
* {Object}
* @param context.mode
* {String} The access mode of the current record. will be one of
* <ul>
* <li>copy</li>
* <li>create</li>
* <li>edit</li>
* </ul>
*
* @return {void}
*
* @static
* @function pageInit
*/
function pageInit(context) {
// TODO
}
function onButtonClick() {
var suiteletUrl = url.resolveScript({
scriptId: 'customscript_depositslip_pdf', //the script id of my suitelet
deploymentId: 'customdeploy_depositslip_pdf', //the deployment id of my suitelet
returnExternalUrl: false,
params: {
custom_id: currentRecord.get().id,
},
});
window.open(suiteletUrl);
}
exports.onButtonClick = onButtonClick;
exports.pageInit = pageInit;
return exports;
});
步驟2)用戶事件腳本創建在我的存款記錄的編輯和查看模式中可見的自定義按鈕,並從我的客戶端腳本調用點擊處理程序。
define([], function () {
/**
*
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @appliedtorecord deposit
*/
var exports = {};
/**
* <code>beforeLoad</code> event handler
*
* @gov 0
*
* @param context
* {Object}
* @param context.newRecord
* {record} the new record being loaded
* @param context.type
* {UserEventType} the action that triggered this event
* @param context.form
* {form} The current UI form
*
* @return {void}
*
* @static
* @function beforeLoad
*/
function beforeLoad(context) {
context.form.addButton({
id: "custpage_printdepositslip",
label: "Print Deposit Slip",
functionName: "onButtonClick"
});
context.form.clientScriptModulePath = "SuiteScripts/ss2-add-button/customDepositSlipButton.js"
}
exports.beforeLoad = beforeLoad;
return exports;
});
步驟3)Suitelet腳本從xml創建相對於當前存款的記錄ID(您點擊按鈕的位置)的自定義表單,該表格從存款子列表中提取信息並將其返回到帶有標題的pdf的有組織表格中如果表需要多個頁面,則會在每個頁面上保留頁腳部分。
define(['N/render', 'N/record', 'N/xml', 'N/format'],
function(render, record, xml, format) {
/**
*@NApiVersion 2.x
* @NScriptType Suitelet
* @appliedtorecord deposit
*/
/**
* <code>onRequest</code> event handler
* @gov 0
*
* @param request
* {Object}
* @param response
* {String}
*
* @return {void}
*
* @static
* @function onRequest
* @function generateXml
*/
function onRequest(context) {
var id = context.request.parameters.custom_id;
if (!id) {
context.response.write('The parameter "custom_id" is required');
return;
}
var xmlString = generateXml(id);
context.response.renderPdf({ xmlString : xmlString });
}
function generateXml(id) {
var depositRecord = record.load({ type: record.Type.DEPOSIT, id: id });
var totes = depositRecord.getValue('total');
var totally = format.format({value:totes, type:format.Type.CURRENCY});
var fulldate = depositRecord.getValue('trandate');
var mmdddate = format.format({value:fulldate, type:format.Type.DATE});
var xml='<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">\n<pdf>\n<head>\n<macrolist>\n<macro id="nlheader">\n';
xml += '<table width="100%" align="center" style="font-size:11px;">\n';
xml += '<tr>\n';
xml += '<td><b>Deposit Number:</b> ' + depositRecord.getValue('tranid') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Date:</b> ' + mmdddate + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Account:</b> ' + depositRecord.getText('account') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Total:</b> ' + totally + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Posting Period:</b> ' + depositRecord.getText('postingperiod') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Memo:</b> ' + depositRecord.getText('memo') + '</td>\n';
xml += '</tr>\n';
xml += '</table>\n';
xml += '</macro>\n<macro id="nlfooter">\n<table style="width: 100%;">\n<tr>\n<td align="right" style="padding: 0; font-size:8pt;">\n<p align="right" text-align="right" ><br /><pagenumber/> of <totalpages/></p>\n</td>\n</tr>\n</table>\n</macro>\n</macrolist>\n</head>\n<body header="nlheader" header-height="13%" footer="nlfooter" footer-height="10pt" padding="0.375in 0.5in 0.5in 0.5in" style="font:10px arial, sans-serif; text-align:left;">\n';
xml += '<table width="100%" align="center" cellpadding="4" cellspacing="0" style="text-align:left; border-left:1px solid #ccc; border-right:1px solid #ccc;">\n';
xml += '<thead>\n';
xml += '<tr style="border:1px solid #ccc; background-color:#efefef;">\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Date</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>ID</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Customer</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Payment Method</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Type</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Ref No.</b></th>\n';
xml += '<th><b>Amount</b></th>\n';
xml += '</tr>\n';
xml += '</thead>\n';
xml += '<tbody>\n';
for (var i = 0; i < parseInt(depositRecord.getLineCount({sublistId: 'payment'})); i++)
{
var amt = depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'paymentamount', line: i});
var payamt = format.format({value:amt, type:format.Type.CURRENCY});
var longdate = depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docdate', line: i});
var shortdate = format.format({value:longdate, type:format.Type.DATE});
if (depositRecord.getSublistText({sublistId: 'payment', fieldId: 'deposit', line: i}) == 'T')
{
xml += '<tr style="border-bottom:1px solid #ccc;">\n';
xml += '<td style="border-right:1px solid #ccc;">' + shortdate + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docnumber', line: i}) + '</td>\n';
var name= depositRecord.getSublistText({sublistId: 'payment', fieldId: 'entity', line: i})
var andName = name.match('&')
if(andName){
var newName = name.replace("&", "&");
xml += '<td style="border-right:1px solid #ccc;">' + newName + '</td>\n';
}
else
xml += '<td style="border-right:1px solid #ccc;">' + name + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistText({sublistId: 'payment', fieldId: 'paymentmethod', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'type', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'refnum', line: i}) + '</td>\n';
xml += '<td align="right" style="text-align:right !important;"><p style="text-align:right !important;">' + payamt + '</p></td>\n';
xml += '</tr>\n';
}
}
xml += '</tbody>\n';
xml += '</table>\n';
xml += '</body>\n</pdf>';
return xml;
}
return {
generateXml:generateXml,
onRequest: onRequest
}
});
我遇到的主要障礙是我們的許多客戶都有客戶名稱的&符號,xml將其解釋為運營商,這需要在“實體”子列表字段中處理條件&符號。 另外,xml想要返回一個更長的日期字段形式,其中包括時間戳,我使用變量和N /格式模塊在結果表單上將日期更改為mm / dd / yyyy格式。
所有這些都會在您的存款屏幕上放置一個標有“打印存款單”的自定義按鈕,或者您在用戶事件腳本中選擇標記它的任何內容。 當你點擊它時,它應該在一個看起來像這樣的新窗口中給你一個pdf表格(請注意,為了這個演示的目的,潛在的敏感信息已經像素化):
就是這樣! 我希望將來可以幫助其他人。
您的Suitelet需要接受一個參數來識別您希望打印哪條記錄:
function onRequest(context) {
var id = context.request.parameters.custom_id;
if (!id) {
context.response.write('The parameter "custom_id" is required');
return;
}
var xmlString = generateXml(id);
context.response.renderPdf({ xmlString: xmlString });
}
function generateXml(id) {
var depositRecord = record.load({ type: record.Type.DEPOSIT, id: id });
var xml = ...
return xml;
}
然后客戶端腳本可以打開Suitelet頁面,傳入當前記錄的內部標識(確保導入N/url
和N/currentRecord
模塊):
function onButtonClick() {
var suiteletUrl = url.resolveScript({
scriptId: 'customscript_printdepositslip', // replace with correct script id
deploymentId: 'customdeploy_printdepositslip', // replace with correct deployment id
returnExternalUrl: false,
params: {
custom_id: currentRecord.get().id,
},
});
window.open(suiteletUrl);
}
免責聲明:上面的代碼未經測試,可能包含語法錯誤!
我無法阻止改善這一點。 這是一個更新的suitelet代碼,它修改了我們的&符號替換,以全局替換實體名稱中的所有&符號實例(是的,我們有一個帶有兩個&符號的客戶)。
此外,我添加了for循環來顯示來自“其他存款”子列表的數據以及當這些子列表中的一個或兩個中存在數據時的“現金返還”。
define(['N/render', 'N/record', 'N/xml', 'N/format'],
function(render, record, xml, format) {
/**
*@NApiVersion 2.x
* @NScriptType Suitelet
* @appliedtorecord deposit
*/
/**
* <code>onRequest</code> event handler
* @gov 0
*
* @param request
* {Object}
* @param response
* {String}
*
* @return {void}
*
* @static
* @function onRequest
* @function generateXml
*/
function onRequest(context) {
var id = context.request.parameters.custom_id;
if (!id) {
context.response.write('The parameter "custom_id" is required');
return;
}
var xmlString = generateXml(id);
context.response.renderPdf({ xmlString : xmlString });
}
function generateXml(id) {
var depositRecord = record.load({ type: record.Type.DEPOSIT, id: id });
var totes = depositRecord.getValue('total');
var totally = format.format({value:totes, type:format.Type.CURRENCY});
var fulldate = depositRecord.getValue('trandate');
var mmdddate = format.format({value:fulldate, type:format.Type.DATE});
var xml='<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">\n<pdf>\n<head>\n<macrolist>\n<macro id="nlheader">\n';
xml += '<table width="100%" align="center" style="font-size:11px;">\n';
xml += '<tr>\n';
xml += '<td><b>Deposit Number:</b> ' + depositRecord.getValue('tranid') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Date:</b> ' + mmdddate + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Account:</b> ' + depositRecord.getText('account') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Total:</b> ' + totally + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Posting Period:</b> ' + depositRecord.getText('postingperiod') + '</td>\n';
xml += '</tr>\n';
xml += '<tr>\n';
xml += '<td><b>Memo:</b> ' + depositRecord.getText('memo') + '</td>\n';
xml += '</tr>\n';
xml += '</table>\n';
xml += '</macro>\n<macro id="nlfooter">\n<table style="width: 100%;">\n<tr>\n<td align="right" style="padding: 0; font-size:8pt;">\n<p align="right" text-align="right" ><br /><pagenumber/> of <totalpages/></p>\n</td>\n</tr>\n</table>\n</macro>\n</macrolist>\n</head>\n<body header="nlheader" header-height="13%" footer="nlfooter" footer-height="10pt" padding="0.375in 0.5in 0.5in 0.5in" style="font:10px arial, sans-serif; text-align:left;">\n';
xml += '<table width="100%" align="center" cellpadding="4" cellspacing="0" style="text-align:left; border-left:1px solid #ccc; border-right:1px solid #ccc;">\n';
xml += '<thead>\n';
xml += '<tr style="border:1px solid #ccc; background-color:#efefef;">\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Date</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>ID</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Customer</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Payment Method</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Type</b></th>\n';
xml += '<th style="border-right:1px solid #ccc;"><b>Ref No.</b></th>\n';
xml += '<th><b>Amount</b></th>\n';
xml += '</tr>\n';
xml += '</thead>\n';
xml += '<tbody>\n';
for (var i = 0; i < parseInt(depositRecord.getLineCount({sublistId: 'payment'})); i++)
{
var amt = depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'paymentamount', line: i});
var payamt = format.format({value:amt, type:format.Type.CURRENCY});
var longdate = depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docdate', line: i});
var shortdate = format.format({value:longdate, type:format.Type.DATE});
if (depositRecord.getSublistText({sublistId: 'payment', fieldId: 'deposit', line: i}) == 'T')
{
xml += '<tr style="border-bottom:1px solid #ccc;">\n';
xml += '<td style="border-right:1px solid #ccc;">' + shortdate + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'docnumber', line: i}) + '</td>\n';
var name= depositRecord.getSublistText({sublistId: 'payment', fieldId: 'entity', line: i})
var andName = name.match('&')
if(andName)
name = name.replace(/&/g, "&");
xml += '<td style="border-right:1px solid #ccc;">' + name + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistText({sublistId: 'payment', fieldId: 'paymentmethod', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'type', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'payment', fieldId: 'refnum', line: i}) + '</td>\n';
xml += '<td align="right" style="text-align:right !important;"><p style="text-align:right !important;">' + payamt + '</p></td>\n';
xml += '</tr>\n';
}
}
for (var i = 0; i < parseInt(depositRecord.getLineCount({sublistId: 'other'})); i++)
{
var amt2 = depositRecord.getSublistValue({sublistId: 'other', fieldId: 'amount', line: i});
var payamt2 = format.format({value:amt2, type:format.Type.CURRENCY});
xml += '<tr style="border-bottom:1px solid #ccc;">\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
var name2= depositRecord.getSublistText({sublistId: 'other', fieldId: 'entity', line: i})
var andName2 = name2.match('&')
if(andName2)
name2 = name2.replace(/&/g, "&");
xml += '<td style="border-right:1px solid #ccc;">' + name2 + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistText({sublistId: 'other', fieldId: 'paymentmethod', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'other', fieldId: 'class', line: i}) + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + depositRecord.getSublistValue({sublistId: 'other', fieldId: 'refnum', line: i}) + '</td>\n';
xml += '<td align="right" style="text-align:right !important;"><p style="text-align:right !important;">' + payamt2 + '</p></td>\n';
xml += '</tr>\n';
}
for (var i = 0; i < parseInt(depositRecord.getLineCount({sublistId: 'cashback'})); i++)
{
var amt3 = depositRecord.getSublistValue({sublistId: 'cashback', fieldId: 'amount', line: i});
var payamt3 = format.format({value:amt3, type:format.Type.CURRENCY});
xml += '<tr style="border-bottom:1px solid #ccc;">\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
var name3= depositRecord.getSublistText({sublistId: 'cashback', fieldId: 'account', line: i})
var andName3 = name3.match('&')
if(andName3)
name3 = name3.replace(/&/g, "&");
xml += '<td style="border-right:1px solid #ccc;">' + name3 + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
xml += '<td style="border-right:1px solid #ccc;">' + '</td>\n';
xml += '<td align="right" style="text-align:right !important;"><p style="text-align:right !important;">' + '(' + payamt3 + ')' + '</p></td>\n';
xml += '</tr>\n';
}
xml += '</tbody>\n';
xml += '</table>\n';
xml += '</body>\n</pdf>';
return xml;
}
return {
generateXml:generateXml,
onRequest: onRequest
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.