Help

TypeError: testRecord.getCellValue is not a function / Issue passing variable from Automation into Script

Topic Labels: Scripting extentions
5351 6
cancel
Showing results for 
Search instead for 
Did you mean: 
Jared_Ingold
6 - Interface Innovator
6 - Interface Innovator

I’m trying to refactor a script that I wrote that is working with a button into a triggered automation. I’m passing the variable “triggeredRecord” using input.config() but for some reason I keep getting the error “TypeError: testRecord.getCellValue is not a function”. I made a test record (testRecord) and I’m getting the same error. What am I missing here?

The main goal here is to just keep “triggeredRecord” available so I can target it using “updateRecordAsync”

6 Replies 6

Welcome back to the Airtable community!

The value you receive from input.config for “triggerRecord” is probably the record ID, which is a string, not an actual record object. In order to use getCellValue you need to have a record object, not just the id.

If you only need the cell value, and not the entire record object, you can pass the cell value into your script using input.config().

You can also run updateRecordAsync using only the cell value from input.config().

I really appreciate the quick response! I messed around with this approach for a while and it still doesn’t seem to fully fix my issue, although it was helpful for me to get my head around the use of input.config().

Unless I’m mistaken, it seems like when I pass in a lookup field cell value into the script it will only let me get the length, but not the array.

Is there a way to get the actual record object or recreate it or search and filter to get it?

Screen Shot 2021-01-21 at 8.19.53 PM Screen Shot 2021-01-21 at 8.20.15 PM

Try “Make a new list of …” … “value”.

Or you could create a rollup field, and use the value of the rollup fields.
Lookup fields are stored internally as arrays, which can be a bit tricky to work with if you are expecting a string.

I did try the “Make a new list of…” and that didn’t work.

The rollup field wouldn’t work for my situation… I need each value so I can run a forEach on it. So there’s no way to get a record object in the automations?

What didn’t work with it? Can you post a screen capture? You should get an array that you can loop through.

You can get the record object in automations. However, you have to do a selectRecordsAsync on the entire table/view, which gets all of the records in the table/view. Then you need to pick out the specific record you want based on the record id. That’s a lot of work compared to getting the value through input variables.

Okay thanks for you help with this. When I originally tried “Make a new list of…” there was only 1 item in that list. So I updated the field, and then retested the trigger but it never pulled multiple in. Every time I tried it I got “1” instead of “1,1,1”.

I just changed the trigger to a new table and then changed it back to make sure it was actually re-testing and that fixed it! I thought that was how that should work but I guess that “test again” doesn’t pull in updated data.