NetSuite SuiteScript 2.0 How do I create a Bank Deposit Slip (suitelet function) from a UserEvent Button












2















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.










share|improve this question



























    2















    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.










    share|improve this question

























      2












      2








      2








      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.










      share|improve this question














      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.






      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;

      });





      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;

      });





      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;

      });





      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;

      });





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





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






      netsuite suitescript2.0






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 0:47









      EFLEFL

      283




      283
























          2 Answers
          2






          active

          oldest

          votes


















          1














          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!






          share|improve this answer


























          • This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

            – EFL
            Nov 15 '18 at 20:22













          • Sorry there was a mistake in the code, try the updated client script

            – michoel
            Nov 15 '18 at 22:37











          • I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

            – EFL
            Nov 15 '18 at 23:50











          • Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

            – EFL
            Nov 20 '18 at 22:28











          • Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

            – EFL
            Nov 20 '18 at 22:51



















          0














          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.






          share|improve this answer


























          • Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

            – EFL
            Nov 27 '18 at 23:33











          • Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

            – Nick
            Nov 29 '18 at 19:25











          • If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

            – EFL
            Nov 30 '18 at 21:24











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310909%2fnetsuite-suitescript-2-0-how-do-i-create-a-bank-deposit-slip-suitelet-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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!






          share|improve this answer


























          • This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

            – EFL
            Nov 15 '18 at 20:22













          • Sorry there was a mistake in the code, try the updated client script

            – michoel
            Nov 15 '18 at 22:37











          • I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

            – EFL
            Nov 15 '18 at 23:50











          • Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

            – EFL
            Nov 20 '18 at 22:28











          • Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

            – EFL
            Nov 20 '18 at 22:51
















          1














          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!






          share|improve this answer


























          • This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

            – EFL
            Nov 15 '18 at 20:22













          • Sorry there was a mistake in the code, try the updated client script

            – michoel
            Nov 15 '18 at 22:37











          • I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

            – EFL
            Nov 15 '18 at 23:50











          • Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

            – EFL
            Nov 20 '18 at 22:28











          • Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

            – EFL
            Nov 20 '18 at 22:51














          1












          1








          1







          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!






          share|improve this answer















          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!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 22:37

























          answered Nov 15 '18 at 2:56









          michoelmichoel

          2,35421014




          2,35421014













          • This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

            – EFL
            Nov 15 '18 at 20:22













          • Sorry there was a mistake in the code, try the updated client script

            – michoel
            Nov 15 '18 at 22:37











          • I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

            – EFL
            Nov 15 '18 at 23:50











          • Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

            – EFL
            Nov 20 '18 at 22:28











          • Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

            – EFL
            Nov 20 '18 at 22:51



















          • This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

            – EFL
            Nov 15 '18 at 20:22













          • Sorry there was a mistake in the code, try the updated client script

            – michoel
            Nov 15 '18 at 22:37











          • I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

            – EFL
            Nov 15 '18 at 23:50











          • Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

            – EFL
            Nov 20 '18 at 22:28











          • Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

            – EFL
            Nov 20 '18 at 22:51

















          This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

          – EFL
          Nov 15 '18 at 20:22







          This is giving me the following message in my error console: Uncaught TypeError: Cannot read property 'newRecord' of undefined at Object.onButtonClick Any idea what I'm doing wrong? If needed, here's a screengrab of the full Client Script, Suitelet code and Error log.

          – EFL
          Nov 15 '18 at 20:22















          Sorry there was a mistake in the code, try the updated client script

          – michoel
          Nov 15 '18 at 22:37





          Sorry there was a mistake in the code, try the updated client script

          – michoel
          Nov 15 '18 at 22:37













          I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

          – EFL
          Nov 15 '18 at 23:50





          I've updated the code & I just realized that, because today was our go-live date, they deleted all of my test deposits - I was looking at the screen in edit mode didn't realize that there were no records. That's why it isn't grabbing the record id - there's no record. Now that the system is live, I'll have to wait until tomorrow when our accounting department will input actual deposits. I'll update you then.

          – EFL
          Nov 15 '18 at 23:50













          Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

          – EFL
          Nov 20 '18 at 22:28





          Update: I'm making progress! I see that I forgot to import the N/currentRecord module on my clientScript. Now it opens the new window but gives me the error: TypeError: Cannot find function getFieldValue in object standard record. I think this is that getFieldValue is from api 1.0 and I need to convert these to getValue from suiteScript api 2.0

          – EFL
          Nov 20 '18 at 22:28













          Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

          – EFL
          Nov 20 '18 at 22:51





          Update: I've changed over all of the xml data pulls to api 2.0 equivalencies and now I get this notice Error Parsing XML: Content is not allowed in prolog. I'm reading up on how to solve this.

          – EFL
          Nov 20 '18 at 22:51













          0














          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.






          share|improve this answer


























          • Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

            – EFL
            Nov 27 '18 at 23:33











          • Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

            – Nick
            Nov 29 '18 at 19:25











          • If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

            – EFL
            Nov 30 '18 at 21:24
















          0














          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.






          share|improve this answer


























          • Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

            – EFL
            Nov 27 '18 at 23:33











          • Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

            – Nick
            Nov 29 '18 at 19:25











          • If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

            – EFL
            Nov 30 '18 at 21:24














          0












          0








          0







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 27 '18 at 22:18

























          answered Nov 27 '18 at 21:32









          NickNick

          277




          277













          • Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

            – EFL
            Nov 27 '18 at 23:33











          • Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

            – Nick
            Nov 29 '18 at 19:25











          • If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

            – EFL
            Nov 30 '18 at 21:24



















          • Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

            – EFL
            Nov 27 '18 at 23:33











          • Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

            – Nick
            Nov 29 '18 at 19:25











          • If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

            – EFL
            Nov 30 '18 at 21:24

















          Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

          – EFL
          Nov 27 '18 at 23:33





          Hi Nick! Thank you! This didn't work for me, but I did finally get past my xml parsing issue (for me the solution was to remove all of the extra spaces and line breaks in my suitelet code, there must have been a few invisible spaces in there somewhere), it's opening my pdf now but it isn't actually bringing in any of my sublist values and I can't figure out why. Is getSublistValue working for you? My pdf looks like this at the moment. And my suitelet looks like this.

          – EFL
          Nov 27 '18 at 23:33













          Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

          – Nick
          Nov 29 '18 at 19:25





          Yeah my getSublistValues are working just fine using the code I posted above, and it looks like your code is almost exactly identical (wierd!). The only thing that comes to mind to check is if the field Ids on your deposit records haven't been altered in any way and aren't something different.

          – Nick
          Nov 29 '18 at 19:25













          If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

          – EFL
          Nov 30 '18 at 21:24





          If I add an else statement into the for loop with hard-coded static values, my sublist line items populate with those static values. This would lead me to believe that my fieldId 'deposit' does not equal 'T' on my payments... How do I fix that?

          – EFL
          Nov 30 '18 at 21:24


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310909%2fnetsuite-suitescript-2-0-how-do-i-create-a-bank-deposit-slip-suitelet-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python