Updating a record through COde Studio

Hopefully, a simple query.

I’m looping through the records in my object as follows…

for (ltime in ltimes){
slot = 0;
slot_found = 0;
while (slot_found === 0){
if (slots_list[slot][mats.ref(‘SlotTime’).trim()] === ltimes[ltime]) {
if (slots_list[slot][mats.ref(‘slotStatus’)] === ‘NULL’) {
if (slots_list[slot][mats.ref(‘SlotService’)] === ‘HPT’) {
cs.log(slots_list[slot][mats.ref(‘SlotDate’)] + slots_list[slot][mats.ref(‘SlotTime’)] + slots_list[slot][mats.ref(‘SlotService’)] + slots_list[slot][mats.ref(‘SlotRoom’)] + slots_list[slot][mats.ref(‘SlotOfficer’)] + slots_list[slot][mats.ref(‘slotStatus’)]);

…The data printed to the console is what I expect. However, I want to update the records, instead of printing them. Using the helpfiles, I replace my “cs.log” statement with…

let record = (slots_list[slot]);

…but in the console I get…

TypeError: record.set is not a function

What am I doing wrong?




The set function is available on instances of the “record” object. I’m assuming (without seeing your earlier code) that slots_list is just an array of arrays, so you would first need to create a record instance using cs.record(). You will need the id of the records to be in your array, such as with the ‘:id’ index in this example:

let record = cs.record(slots_list[slot][’:id’]);


Works perfectly.

Many thanks for your help.