3
votes

I'm a non-developer who's brand new to NetSuite and SuiteScript and I'm stumbling my way through.

The problem: For each deposit record I need to create a printable pdf which lists each of the payments on that record (a Bank Deposit Slip). I would like to call this pdf on a custom button to display in a new window that I can print from. I do not need to save the document in the file cabinet.

1. Right now I have a UserEvent button that shows up on Deposits in view and edit modes.

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. This button calls a clickhandler function "onButtonClick" from a ClientScript named "customDepositSlipButton.js"

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;

});

Currently this works, but only creates a dialog popup for testing purposes. So far, so good. testing popup

And here's where I'm stuck: I don't understand how to now connect this to a function on a Suitelet which should generate a pdf file from xml.

3. I've set up a Suitelet with a pdf from xml script in that same file cabinet location titled "depositSlipPDF.js" with the function "generatePdfFileFromRawXml" as follows.

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
    }
});

How do I call generatePdfFileFromRawXml(); from onButtonClick();?

Credit for getting this far goes to Stoic Software where SS2 is made understandable (thank you, Eric) and to teamtag for this post where I'm getting the code for these initial xml data pulls.

4

4 Answers

2
votes

I too, am trying the same thing. Mine is finally working, try changing your xml string to:

    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>'; 

and see if that fixes your Parsing XML error.

3
votes

Using input from both of the previous answers, here's the full working solution and screenshot of the result:

Step 1) Client Script to establish a click-handler for a custom button, this grabs the id of my current record and passes it to my suitelet which executes in a new window

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;
 });

Step 2) User Event Script to create a custom button visible in both edit and view modes of my deposit record and calls the click-handler from my Client Script.

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;
 });

Step 3) Suitelet Script to create a custom form from xml relative to the record id of the current deposit (where you clicked the button), which pulls info from the deposit sublist and returns it in an organized table in a pdf with a header and footer section that persist on each page if the table requires multiple pages.

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("&", "&amp;");
                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
  }
});

The major hurdle I ran in to was that many of our customers have ampersands in their customer name and xml was interpreting this as an operator, this required the conditional ampersand handling on the "entity" sublist field. Additionally, xml wanted to return a much longer form of the date field which included time stamps, I'm using variables and the N/format module to change the date into a mm/dd/yyyy format on the resulting form.

All of this will put a custom button on your deposit screen labelled "Print Deposit Slip" or whatever you choose to label it in your User Event Script. And when you click on that, it should give you a pdf form in a new window that looks like this (note that potentially sensitive information has been pixelated for the purposes of this demo):

NetSuite Bank Deposit Slip from Suitelet

And that's it! I hope this helps someone else out in the future.

1
votes

Your Suitelet will need to accept a parameter to identify which record you want it to print:

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;
}

Then the client script can open the Suitelet page, passing in the current record's Internal Id (make sure you import the N/url and N/currentRecord modules):

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);
}

DISCLAIMER: above code is untested and may contain syntax errors!

0
votes

I can't stop improving this. Here's an updated suitelet code that modifies our ampersand replacement to globally replace all instances of ampersands in an entity name (yes we had a customer with two ampersands).

Additionally, I've added for loops to display data from the "Other Deposits" sublist as well as for "Cash Back" when data exists in either, or both, of these sublists.

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, "&amp;");
        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, "&amp;");
        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, "&amp;");
        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
  }
});