I sell widgets and the quantity of widgets generates will generate (with a formula) the number of boxes that will be required to ship the order. I have a view filtered for orders ready to ship and export this information to a .csv and then import the orders into my shipping application, stamps.com. Upon import, each row corresponds to a shipping label. The challenge is that I have to duplicate the rows x number of times to match the required number boxes.
Is there a way to way to automate this process? My hunch is that it can be done with a script. However, I have 0 experience working with scripts. I’m happy to learn if this is the case and someone wants to point me in the right direction. I also have Zapier at my disposal if this helps solve the problem.
Yep, this is definitely a great use-case for the Scripting block.
In your table setup, I’d suggest having 2 fields in place:
The “Duplicates to Make” integer field you already mentioned
A “Duplication Done” checkbox field to ensure you don’t create erroneous duplicates
The script will operate on a View filtered to show only records WHERE “Duplicates to Make” has a value AND WHERE “Duplication Done” == False (or 0).
The script can query all the records from that view, loop over them, and for each, create a number of new records equal to the number in “Duplicates to Make”, populating those new records with data from the original. Once the duplicates are made, the script could check the “Duplication Done” checkbox field.
I don’t have time right now to dive into the script itself, but I bet you could make a good start of it if you dive into the documentation
I am stuck trying to figure out how to define the view that the records are pulled from. I’ve tried several variations of the following line of code with no luck.
That looks right to me … as long as table is actually holding a table object!
The editor should give you pointers as to whether you’re on the right track – if you have a valid table object, when you call .getView(...) off of it, and you hit that first quotation mark, the Intellisense context menu in the editor should show you all of the View names available in that table object, like so:
I didn’t have to do anything special to get those to come up as options – I just instantiated a valid table object, called .getView() off of it, and as soon as I typed the first ", that context menu popped up showing me the names of all my views in that table.
So if that line you have there isn’t working, I’d suggest that maybe you aren’t properly instantiating your table object first.