By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript One row input - multiple rows output


New Coder
Hi all,

I’m new go coding. I created an app using Zoho with their Deluge language, but I now want to attempt to recreate it in Google Sheets using App Scripts. I believe App Scripts is based on JavaScript.

I’ve had fun creating mini-scripts using some youtube videos that swap columns, filters arrays etc. But there is one conceptual gap missing that I need to plug.

What my app is suppose to do is take rows of of input data with just five columns and create a new table with more rows and columns based on a few simple rules. It’s for bookkeeping so it’s turning transaction data into bookkeeping data.

E.g. one row will have a Date/Description/Category/Amount/Location of a transaction.
This should then be transformed to multiple rows a for double entry bookkeeping:

  1. Date/Description/Category/Amount/Location/Account/Credit/Debit (maybe a row ID too)
  2. Date/Description/Category/Amount/Location/Account/Credit/Debit (maybe a row ID too)
    the one input row would trigger at least two rows in the new sheet whereby one “Account” (say Expense) would be Credited and another “Account” (say revenue) would be Debited.
[the value entered into the new columns would be based on the category in the input data]

So my app would need to
1 Capture the input data into an array
2. Filter the array per category
3. Each category would have a different set of rules, whereby it would create multiple new rows in a new array with additional columns, as above,
4. apply the different rules to different groups of filtered categories
5. write the new data in a new sheet.

The bit I can’t find anything on google searches so far is the creation of multiple new rows, based on the input of one row. So once I filtered for a category, say Expenses, I would want to write at least two new rows to debit one account and credit another.

Can anyone point me to tutorial of some nature that can set me on my path to understanding how to do this?

Many thanks,
Top Bottom