Using a script to add values from one field to another

Topic Labels: Scripting extentions
18056 31
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

Non-developer type here! My team is using Airtable as a task management tool Each week we run a report, which includes a long text field (“Details Field”) with details on the work performed on a specific task during that week. To retain a record of the content that’s appeared in the Details Field, I wonder if it would be possible to write a script that would copy and clear the values of the Details Field and cumulatively add them to a field (“History Field”). The History Field would then eventually contain a list of all the updates that’s been put into the Details Field over time (and ideally with date stamps to next to the text that was copied at a given time).

Thanks so much for your feedback on this!


31 Replies 31

@Mohd_Abdulatef, yes, as per @kuovonne, the error is saying that the two multi-select fields don’t have the same options, which is required for this particular script to work.

4 - Data Explorer
4 - Data Explorer

Hey Everone! Similar to @Jens_Schott_Knudsen1 above, I’m wondering if I could get some scripting help. It’s super similar to her request (but not similar enough for me to figure out on my own…).

I’m looking for a script that will take a numerical value from one “Added Quantity” and add it to a numerical value in “Current Quantity” … then clear the “Added Quantity” cell.

Is anyone able to give me a hand with this one? I can’t crack the code and am not much of a script’er :frowning:


  • Adam

Hi @Adam_Finley, were you able to find a solution to this? I have a similar issue.



I did. I ended up solving this with three automatons. The first automation takes the input value from Cell 1 and adds it to Cell 2. The second automation takes the Cell 2 value and copies it to Cell 3. The third automation clears Cell 1 and re-sets it back to zero. So when you input a value in Cel 1, at the end of the automation, it is added to Cell 3, Cell 1 is cleared and ready for a new input value :slightly_smiling_face:

Such a cool example and an excellent script for an Airtable Script App introduction.

Thanks to your post - Airtable scripts are all starting to make sense to me. So much so that I modified your original script to remove a “null” string bug and also amended the output with the copied notes detail.

// set the table
let notesTbl = base.getTable("Notes");
// get the table records
let notes = await base.getTable("Notes").selectRecordsAsync();

// loop through the records
for (let record of notes.records) {
    // set variables to the record values
    let notes = record.getCellValue("Notes");
    let notesHistory = record.getCellValue("Notes History")
    //clear the History cell for first entry - removes "null" string
    if (notesHistory == null)  {
      notesHistory = ""
    // set variable for today's date
    let now = new Date().toLocaleDateString("en-GB");
    // define the newNotes variable with starter text (includes the date)
    let newNotes = "======= Copied " + now + " ======= ";
    // only run on records which have notes
    if (notes) {
        output.text(`Copying notes "${notes}" for record ${}`) //print notes in debug.
        // build the newNotes value from the notes...
        newNotes = newNotes + notes;
        // ...and the notes history 
        newNotes = newNotes + notesHistory;
        // update the notes history value and reset the notes value
        notesTbl.updateRecordAsync(record, {
            "Notes History": newNotes,
            "Notes": ""
} here

Oh man, I’m going to lose hours… days? to Airtable scripts! So cool!

@Karlstens - good spot. We can actually simplify this further with a ternary:

    let notesHistory = record.getCellValue("Notes History")
    //clear the History cell for first entry - removes "null" string
    if (notesHistory == null)  {
      notesHistory = ""

could be:

    let notesHistory = record.getCellValue("Notes History") ? record.getCellValue("Notes History") : ''

Hi guys!

I found your article and its very powerful script.
Was looking for it for a long time.
Im trying to use it as an automation - when Notes is updated, tu run this scrip.

But I have the next log issue:

TypeError: output.text is not a function
at main on line 21

do you have any ideas why it does’t want to run in automation ?
P.S. if tu use the same script via Scrip app - it works great!

output.text is not available in automation scripts, only scripting app. Because there is no user looking at a screen when an automation runs, there is no need for output.

You can comment out that line or you can change output.text to console.log.

I’m a bit late to this but IMO short-circuiting here would be preferable both in terms of performance and readability:

let notesHistory = record.getCellValue("Notes History") || ''

Brilliant. Thanks!

jp logo.png

4 - Data Explorer
4 - Data Explorer

I think I’m looking for a script similar to this but can’t figure out how to adapt it.
I have a ‘link’ column and I’d like to run a script that whenever is finds a word like ‘amazon’ within the link, it populates my ‘vendor’ column which is a multi-select column with the ‘amazon’ vendor.
Does that make sense?

4 - Data Explorer
4 - Data Explorer

Is there a way to use the same script, but instead of strings, it adds integers or numbers into the new field (which is also an integer rather than string)?