
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 06, 2021 06:36 AM
Hello,
I am trying to update linked fields but I am getting an error. I know updating linked fields is challenging in Airtable so I went for the scripting route.
Find my code below:
//grab info from TF inputs
let TFinputs = base.getTable("Fishel Inputs 2021");
let TFview = TFinputs.getView('Update Leaf Lease');
// grab record from previous input
let TFRec = input.config();
let queryTFinput = await TFview.selectRecordsAsync(); // get all records in TF inputs
let updated_record = queryTFinput.getRecord(TFRec.TFRec);
let TFPoleNum = updated_record.getCellValueAsString("Pole # Fix");
let TFPanelBar = updated_record.getCellValueAsString("Panel Barcode");
let TFLightBar = updated_record.getCellValueAsString("Light Barcode");
let TFPoleBar = updated_record.getCellValueAsString("Pole Barcode");
let TFDateIn = updated_record.getCellValueAsString("Day of Entry");
console.log(updated_record)
//grab record to update
let SLLease = base.getTable("Street Leaf Lease TEST");
let SLLview = SLLease.getView('Vanilla');
let querySLLease = await SLLview.selectRecordsAsync(); // get all records in SLLeaselet
var SLLPoleNum
// find record in array
for (let record of querySLLease.records) {
// paste record found in TF clone
if (record.getCellValue("Pole Number") == TFPoleNum){
SLLPoleNum = record
console.log(SLLPoleNum)
//await TFinputs.updateRecordAsync(TFRec.TFRec, {
// "Record ID to update": SLLPoleNum
//});
SLLease.updateRecordAsync(SLLPoleNum, {
'Light #': [
...SLLPoleNum.getCellValue('Light #'),
{id: updated_record.id}
]
});
};
};
With this I am getting
ERROR
TypeError: SLLPoleNum.getCellValue is not a function or its return value is not iterable
at main on line 41
The script is successful at pulling all the data it needs and finding the record to update and its relative fields to update but for the love of god I am not able to update the data in the field.
Light is just one of the fields I want to update, the complete list is all the “Barcodes” and “Date”
HELP please and thank you
0 Replies 0
