Help

Re: Help with a simple script - using variable field value

Solved
Jump to Solution
1502 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Michael_Andrew
8 - Airtable Astronomer
8 - Airtable Astronomer

Here is my script. The goal is to copy a value from a field into another field, but the field variable is dynamic. The fields do exist and will match the fieldvalue input variable. However, i don’t seem to be able to update the record by using a defined variable. Here is my script:

let config = input.config()
let recordId = config.recordid
let name = config.fieldvalue
let table = base.getTable(“Verifier / Trainer Body”)
let query = await table.selectRecordsAsync()
let record = query.getRecord(recordId)
let field = table.getField(name)
let fieldval = field.id
console.log(fieldval)
let value1 = record.getCellValue(“VB Total Score”)
let copy = await table.updateRecordAsync(record,{fieldval:value1})

Thoughts?

1 Solution

Accepted Solutions
Kamille_Parks
16 - Uranus
16 - Uranus

Try adjusting ^that line as:

let copy = await table.updateRecordAsync(record,{[fieldval]:value1})

Also make sure the supplied field value matches a format the relevant field-type accepts. For instance, the field value for a single select field returns something like {name: "a", color: "b", id: "c"} but accepts values like {name: "a"} or {color: "b"}.

See Solution in Thread

2 Replies 2
Kamille_Parks
16 - Uranus
16 - Uranus

Try adjusting ^that line as:

let copy = await table.updateRecordAsync(record,{[fieldval]:value1})

Also make sure the supplied field value matches a format the relevant field-type accepts. For instance, the field value for a single select field returns something like {name: "a", color: "b", id: "c"} but accepts values like {name: "a"} or {color: "b"}.

stupid brackets :face_with_raised_eyebrow:

Thanks!