Use Case:
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
Thank you Jeremy for the quick response and for pointing me in the right direction. Iāll post the solution (when I work it out) for the benefit of the AirTable community.
After a few unsuccessful attempts at writing a script from scratch, Iāve come to guess that Iām a bit over my head. Without first learning some Javascript basics Iām kinda swinging blind. Instead of bothering everyone with questions that I would learn if I just starting learning js from the beginning, I went searching (again) for a script I could copy and paste. I found this great post (only a few days old) by Kuovonne Voderbruggen (@kuovonne ) that does most of what Iām trying to accomplish. See the post here: https://community.airtable.com/t/weekend-scripting-block-challenge-and-1-000-prize/28074/9
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.