Airtable has been a godsend to our organization, but none of us are very familiar with scripting. We have a need for a what I imagine is a simple script, but the examples I’m finding in the community and outside are much more complicated.
We have a few employees who only add simple orders in between their tasks. Normally we would do this with a form, but the multi table process is frustrating. Basically we have 3 tables Customers, Orders, and Order Line Items. I want to add a button to our Customer table that runs a script that creates a linked record to that customer in the Orders table with today’s date and then launches our Order Line Items Form with the “Order” field prefilled with the record just created.
That way from a read only share of our base they can hit the button and (in the background) an order is created and the form to add items is automatically launched.
The examples I am finding around seem much more complicated and I’m having trouble parsing them.
Thanks for you help.
You don’t need a script to do that. You can just do that with a basic automation.
When a new record is created in the customers table, create a new record in the orders table and set the linked record field to the customer ID. Then, create a new record in the line items table and set the linked record field to the order ID.
For the date field in the orders table, just add a “created time” field. You can also automate putting that into a normal date field, too.
Hmm I’m not sure that works exactly. Part of the issue is that this is needs to be read-only base solution. We have a small team and giving 3 people Airtable accounts when this would be ~3% of their job doesn’t really make sense. So they do not have the ability to create the records themselves … hence the need for a button (which can be pushed from read-only account/share view).
The Customers base doesn’t need to be changed at all … this is just where the button would live (to trigger which Customer to link the new order to). Also one customer can have multiple orders, so “new record” or “new record in view” wouldn’t be a reliable Automation trigger.
Right now we have am “Order” form where they choose a customer and a date (there’s other stuff as well, but none of it is necessary and all of it can be added later via form). Then we have an “Add items to order” form where they need to select the order they just made and add items/quantities. It’s just a bit clunky and I’m hoping it can be more streamlined.
Read-only users cannot push a button that runs a script that directly creates a record. A script that runs from a button uses the permissions of the person pushing the button.
In order for a read-only user to create records, you must use a 3rd party integration/portal, or an Airtable form.
However, you can create a new linked record by using an open url button. Have the formula for the button calculate the prefilled url for the record. You can use the Prefilled Form app to build the formula.
In your use case, you would need two prefilled url buttons, one in the customer table to create the linked order, and another in the order table to create the linked line items.