Hello all,
I’ve been updating a Record in a Linked Table to point to a different Main Record using the below code;
let _ins = input.config();
let main_table = base.getTable("Main Table");
let linked_table = base.getTable("Linked Table");
let main_rec = _ins._get_record;
let linked_rec = _ins._get_linked_record;
let linked_val = _ins._get_linked_value;
console.log(`main_rec: ${main_rec}`);
console.log(`linked_rec: ${linked_rec}`);
console.info(`linked_val: ${linked_val}`);
if (linked_val == "Not Listed") {
console.warn("Not Listed - Clearing and rewriting entry");
await linked_table.updateRecordAsync(`${linked_rec}`, {
"Linked Text": `Example updated ${linked_table} record text`,
//"Main" : [{id:`${main_rec}`}] //Field is updated with expected record via recordID
"Main" : [{id:`${""}`}] //Attempt to clear field is not working...
});
console.info(`Updated Table "${linked_table.name}" record ${linked_rec} with "${main_rec}`);
};
This particular line of code works, updating an entry
//Field is updated with expected record via recordID
"Main" : [{id:`${main_rec}`}]
But what if I want to update the entry with a blank value, clear out the field for that record?
// Attempt to clear field is not working
"Main" : [{id:`${""}`}]
I’ve tried null, undefined, and a few other ideas - none of which are executing. Keen for some help if anyone can spare a moment.
I’m also keen to rewrite my code with more direct calls. For example, although this works it makes me feel uneasy, and I’d like to know the preferred syntax;
await linked_table.updateRecordAsync(`${linked_rec}`, {}
I’m sure I’m not to be using string literals for record ID lookups :joy: … yeah it works, no I’m not proud of it. Appreciate some pointers!
