Jun 23, 2021 11:36 AM
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?
Solved! Go to Solution.
Jun 23, 2021 12:19 PM
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"}
.
Jun 23, 2021 12:19 PM
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"}
.
Jun 23, 2021 02:56 PM
stupid brackets :face_with_raised_eyebrow:
Thanks!