Help

Re: Create Records by combining 2 columns - Date Column & Multiple Select

Solved
Jump to Solution
2764 1
cancel
Showing results for 
Search instead for 
Did you mean: 

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
image

How do I achieve this using a button?

Thanks.

12 Replies 12

Another great option for learning JavaScript online is www.freecodecamp.org

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)

That is handy! Thanks for the tips!