Jun 20, 2022 06:07 AM
Hi guys,
Need your help in scripting. I want to concatenate month and templateName to another table using scripts as individual records.
My desired output is e.g.
templateMonth; templateName
2022-01; HD-HD1460, TR144 | 1 x RM-HD
2022-01; HD-WHITE | 5 x RM-HD, 1 x RM-WHITE
How do I achieve this using a button?
Thanks.
Solved! Go to Solution.
Jun 23, 2022 09:29 AM
Another great option for learning JavaScript online is www.freecodecamp.org
Jun 23, 2022 04:45 PM
Hi,
I can repeat once again - Airtable is a great playground to learn programming, where you can use most efficient way to learn - to create scripts, that solve real-life tasks, by your own hands. Thanks to pro developers who created here scripts simple enough to be understandable for beginners and with a lots of comments.
I would suggest to learn array transforming functions, where you can use some common reusable pieces.
I like to learn from experts here. Now I prefer to use arrow functions, like let double=x=>x*2
, use const almost everywhere, if this variable not expected to be mutated, and reuse much of functions in different scripts.
Of course it’s all “a matter of taste”.
I always had difficulties with correct format to update or create records - because started work in Airtable as DBA, without clear understanding of arrays and objects. At first, even ‘push’ was a great improvement for me
For example, instead of
// Create records
let dToCreate = [];
for (let i = 0; i < length; i++) {
let name = delivNames[i].Name
dToCreate.push({
fields: {
[s.destinationField.id]: name,
[s.projField.id]: [{ id: r.id }]
}
})
};
You can use something like:
let create=el=>({ fields: {[s.destinationField]: el.name, [s.projField.id]: [{ id: r.id }] }})
let dToCreate=delivnames.map(create)
Jun 24, 2022 01:26 AM
That is handy! Thanks for the tips!