Help

Troubleshooting Automations

Topic Labels: Automations
4394 11
cancel
Showing results for 
Search instead for 
Did you mean: 
Bart_Hutton
5 - Automation Enthusiast
5 - Automation Enthusiast

I recently discovered Automation feature, and I would like to replace my many dozens of Zapier zaps. However, I am having trouble finding any documentation about it. There isn’t even a community tag for it! When I do any kind of search I come up with nothing. Anyway, I’m stuck in a couple of places, and I could use some help!

I have a very large and kludgy Airtable base for my work that has Projects, People, Tasks, LineItems… over 30 tables, and the information is all connected, which is the purpose of Airtable! The most typical automation is to create a new linked record in several tables when a project is created.

First I found a Script that would do this, and it works great when I click the button. So I copied the script into the Automation to be triggered automatically, and even though I’m passing in the RecordID using the config structures, I just can’t figure out how to make it work. I could use some help there. Here’s the code:

let config = input.config();

let recordId = config.recordId;

let ownerId = config.taskOwnerId

console.log(recordId);

console.log(ownerId)

let table = base.getTable("Timesheet Entries");

let query = await table.selectRecordsAsync();

let record = query.getRecord(recordId);

await table.updateRecordAsync(recordId, {

"Owner": [{id: recordId}],

});

When I run the test it just spins and times out. I would prefer to use scripts to do this kind of operation, but I discovered that creating new records is available as actions. So I tried that, and it works for most of my use cases. When a Project record is added a couple of default budget items are created. In our system, Tasks are children of Budget Items, and I would like to create a default task with the project owner as the task owner. BudgetItem has a lookup for Owner, and I can reference the ownerID, but the test fails.

In other words, using recordID’s pulled from lookups (or a text, I tried that too) throws an error when trying to use that ID to create a new link. (project => budget item => task linked to project owner)

What am I doing wrong?

11 Replies 11

Lookups are great if you don’t need to do much (data-wise) with what you’re looking up, other than see it in the base. The moment you need to actually take that looked-up data and use it elsewhere, it can become troublesome if you don’t remember that it’s most likely outputting an array.

This is a bit of an oversimplification, but a rollup is largely a lookup with a built-in formula. If you don’t use an aggregation formula, it’ll output an array just like a lookup does. However, you can’t always get the same result by using both a lookup and a formula field vs a rollup with its built-in formula, as some functions behave slightly differently inside rollup fields compared to formulas.

Glad you were able to work it out. If you want to limit extaneous fields in your base you could probably force the Lookup value to be a string in the script using ownerId.toString() or String(ownerId).