Possible to replicate "Multiple rows per record" functionality with script?
Hello,
I have a scenario where the out-of-the-box IIO Multiple rows per record feature isn't working (unsorted input data). As you know, this feature creates nested arrays of grouped records that IIO then treats as single records. I'm wondering if I can create my own grouping in a script? Can I take ungrouped input records, group them and hand the callback a nested array of grouped results? I'm not sure if it's simply the format of the JSON that provides all the hints to the system or if there is metadata behind the scenes that tells the system to treat the data as grouped.
Regards,
Steve
0
Comments
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:
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.
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.