Hello,
I’ve been trying out a couple of ideas for table linking via Linked Fields and Automation. One particular idea lead me to creating multiple Rollup Fields, that then all need to be returned into a linked field via an Automation.
There’s a few ways to do this. One method is scripting the entire solution within an Automation - but I’m exploring non-script methods - but my troubles are with the array construction that the Automation then copies.
Here’s one example table - please excuse my spaceship terminology :grinning_face_with_sweat: :rocket:
At the moment, I’m using the below formula, but feel that it’s just a bit too much? Is there not a simpler way to write this?
CONCATENATE(
IF({Chassis (Frigate Class)} ,{Chassis (Frigate Class)} & ", " ,""),
IF({Chassis (Destroyer Class)} ,{Chassis (Destroyer Class)} & ", " ,""),
IF({Chassis (Capital Class)} ,{Chassis (Capital Class)} ,"")
)
An Array function that could be written as this would be amazing :sparkles:
MagicArray({Chassis (Frigate Class)},{Chassis (Destroyer Class)},{Chassis (Capital Class)} )
I’m hoping there is, but can’t seem to find it in the manual. :cry: Perhaps at least, there’s an easier method where I use Concatenate, and then remove duplicate/triple/quadruple commas with Regex replace? … but at least my current stacked If statement method works.
Alternatively to formula fields, it would be great if we could bypass the Calculation Formula Field completely, and somehow enter the dynamic fields directly into an Automation.
But this method fails as soon as one of the returns is blank and there’s a double comma - hence me exploring formulas.
Keen to hear thoughts!
EDIT:
I’ll need to sleep on it some more, but I think I’m leaning more in favour to actually scrap the formula and rollup columns, and simply execute a script off of a Lookup column.
But one reason I’m still interested in this problem, is that it seems like there’s an almost do-able solution to this problem without the need to go full-blown-JS (which don’t get me wrong, I’m now a sucker for this punishment :rofl: )
let inputConfig = input.config();
let table = base.getTable("Sheild Technology");
let record = await table.selectRecordAsync(inputConfig.recordId, {
fields: [
"Name",
"Chassis (Frigate)",
"Chassis (Destroyer)",
"Chassis (Capital)"
]
});
console.log(record?.getCellValue("Chassis (Frigate)"));
console.log(record?.getCellValue("Chassis (Destroyer)"));
console.log(record?.getCellValue("Chassis (Capital)"));
let chassisArray = Array.from(new Set([
...record?.getCellValue("Chassis (Frigate)") ?? [],
...record?.getCellValue("Chassis (Destroyer)") ?? [],
...record?.getCellValue("Chassis (Capital)"??) []
]));
console.info(chassisArray)
let chassisData = chassisArray.filter( element => element != null ).map( element => ({
"id" : element
}));
await table.updateRecordAsync(inputConfig.recordId, {
"Chassis": chassisData
})