Possible to replicate "Multiple rows per record" functionality with script?



  • Official comment
    Lucian Hymer Senior Solutions Consultant

    Hey Steve,

    Yes you can certainly do this in a script. You'd want to use a preSavePage hook on the export. Basically you just need to ensure that the "data" object in your return is an array. IO will treat each object within that array as a separate "record", so if you want to group multiple data records together, you'll want to essentially push them down into one of these objects. You can do whatever grouping logic you want. For example:

    rows: [{
    transaction_id: 1,
    line_id: 1
    }, {
    transaction_id: 1,
    line_id: 2
    rows: [{
    transaction_id: 2,
    line_id: 1

    This example started with 3 records, but it grouped them according to their trasaction_id and resulted in two effective records. All the bold stuff in the example above belongs to one "record" now. 

    Here's a little 5-line script that I commonly use when I want to group all rows.

    function preSavePage (options) {
    return {
    data: [{rows: options.data}]
  • Chirag2006
    Celigo University Level 3: Master

    Hi Lucian Hymer,

    I have a use case, where I have to create a NetSuite vendor bill from database tables. The problem I am facing an issue as a vendor bill can have multiple lines and the lines will be individual database table records. So, I have to group those lines based on some common database field value.

    Can you help me with this?

    Thanks in advance :)


Please sign in to leave a comment.