Help with a simple script - using variable field value

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?

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"}.

1 Like

stupid brackets :face_with_raised_eyebrow:

Thanks!

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.